This is what DMD does, and arguably the expected behavior – otherwise,
there would be no way other than using -od to prevent races if two
compiler instances could ever compile the same file(s) at the same
time (e.g. for debug/release configurations).
Should we transition to assuming -singleobj by default?
A lot of system specific knowledge is already present in LLVM. This is used to populate several fields in global.params instead of hard coded values in main(). Ensures that the frontend and LLVM have always the same values.
The string representation of the data layout is retrieved from the TargetData class (in main) and passed via global.params.dataLayout to the module. Since the gTargetData is also a global variable it makes no sense to pass this information using another global variable.
The Windows linker LINK insists on the .obj extension. The following changes are made:
- CMake uses the same extension as the C compiler
- global.obj_ext_alt (aka .obj) is recognized as objectfile extension
- global.obj_ext_alt is used on Windows
- New functions codeGenOptLevel() and verifyModule() to remove code duplication
- Hidden option no-verify renamed to disable-verify and moved to optimizer (like opt tool)
- Removed global.params.noVerify
This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.