Clang-cl crosscompilation fails to compile inial C/CXX programs as x86
Hi, I've got clang-cl toolchain which works for x64. But I failed to use it for x86, despite changing to x86 libs
link_directories(/var/win10_sdk/lib)
link_directories(/var/win10_sdk/lib/um/x86)
link_directories(/var/win10_sdk/lib/ucrt/x86)
...
set(MSCV_C_ARCHITECTURE_ID x86)
set(MSCV_CXX_ARCHITECTURE_ID x86)
The same despite removing - SET(CMAKER_VS_PLATFORM_TOOLSET v140)
and SET(ARCH_ x64)
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DCMAKE_TOOLCHAIN_FILE=../scripts/cmake_msvc2015_wine.cmake --trace-expand &> cmake_trace.log
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61c1d.dir/link.txt --verbose=1
/usr/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_61c1d.dir --rc=/usr/lib/llvm-10/bin/llvm-rc --mt=/bin/true --manifests -- /usr/lib/llvm-10/bin/lld-link /nologo @CMakeFiles/cmTC_61c1d.dir/objects1.rsp /out:cmTC_61c1d.exe /implib:cmTC_61c1d.lib /pdb:/TP/build/CMakeFiles/CMakeTmp/cmTC_61c1d.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console -LIBPATH:/var/win10_sdk/lib -LIBPATH:/var/win10_sdk/lib/um/x86 -LIBPATH:/var/win10_sdk/lib/ucrt/x86 kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
LINK Pass 1: command "/usr/lib/llvm-10/bin/lld-link /nologo @CMakeFiles/cmTC_61c1d.dir/objects1.rsp /out:cmTC_61c1d.exe /implib:cmTC_61c1d.lib /pdb:/TP/build/CMakeFiles/CMakeTmp/cmTC_61c1d.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console -LIBPATH:/var/win10_sdk/lib -LIBPATH:/var/win10_sdk/lib/um/x86 -LIBPATH:/var/win10_sdk/lib/ucrt/x86 kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_61c1d.dir/intermediate.manifest CMakeFiles/cmTC_61c1d.dir/manifest.res" failed (exit code 1) with the following output:
lld-link: error: <root>: undefined symbol: mainCRTStartup
I've compared list of libraries and it's the same as for x64.
Yet, I can't change /machine:x64
to x86. --trace-expand
reveal that this depends on MSVC_C_ARCHITECTURE_ID and MSVC_CXX_ARCHITECTURE_ID values in /usr/share/cmake-3.16/Modules/Platform/Windows-MSVC.cmake(249)
.
Given symbol is in libcmt.lib or msvcrt.lib libraries which are present in given folders. They weren't explicitly placed in lld-link command parameters.
Now I suspect /machine:x64
as responsible for NOT finding right symbols/libraries. But I don't know how to change it to other values. It's not MSVC - where generator allowed to use -AWin32
. This is Unix Makefile
.
EDIT: The same problem is with clang-cl
as for 32b build I need to use define -m32
otherwise -m64
. It would be nice to control both parameters (machine
for link and -mxx
for compilation`)