www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Building LDC on windows, woe is me!

reply claptrap <clap trap.com> writes:
Ok been banging my head against this for a few hours and getting 
nowhere. Following the windows build instructions up to the point 
of generating NINJA build files...

cmake -G Ninja ..\ldc -DCMAKE_INSTALL_PREFIX="C:\LDCDEV\LDC-x64" 
-DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DLLVM_ROOT_DIR="C:/LDCDEV/LLVM-x64"

gives me this...

=================
     kind: "try_compile-v1"
     backtrace:
       - "C:/Program 
Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerABI.cmake:57
(try_compile)"
       - "C:/Program 
Files/CMake/share/cmake-3.27/Modules/CMakeTestCCompiler.cmake:26 
(CMAKE_DETERMINE_COMPILER_ABI)"
       - "CMakeLists.txt:15 (project)"
     checks:
       - "Detecting C compiler ABI info"
     directories:
       source: 
"C:/LDCDEV/build-ldc-x64/CMakeFiles/CMakeScratch/TryCompile-bp4cti"
       binary: 
"C:/LDCDEV/build-ldc-x64/CMakeFiles/CMakeScratch/TryCompile-bp4cti"
     cmakeVariables:
       CMAKE_C_FLAGS: ""
       CMAKE_EXE_LINKER_FLAGS: ""
     buildResult:
       variable: "CMAKE_C_ABI_COMPILED"
       cached: true
       stdout: |
         Change Dir: 
'C:/LDCDEV/build-ldc-x64/CMakeFiles/CMakeScratch/TryCompile-bp4cti'

         Run Build Command(s): C:/NINJA/ninja.exe -v cmTC_90234
         [1/2] 
C:\\PROGRA~2\\MICROS~2\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\
ostx64\\x64\\cl.exe  /nologo   /MDd /Zi /Ob0 /Od /RTC1 /showIncludes
/FoCMakeFiles\\cmTC_90234.dir\\CMakeCCompilerABI.c.obj
/FdCMakeFiles\\cmTC_90234.dir\\ /FS -c "C:\\Program
Files\\CMake\\share\\cmake-3.27\\Modules\\CMakeCCompilerABI.c"
         [2/2] cmd.exe /C "cd . && "C:\\Program 
Files\\CMake\\bin\\cmake.exe" -E vs_link_exe 
--intdir=CMakeFiles\\cmTC_90234.dir --rc=rc 
--mt=CMAKE_MT-NOTFOUND --manifests  -- 
C:\\PROGRA~2\\MICROS~2\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\Ho
tx64\\x64\\link.exe /nologo CMakeFiles\\cmTC_90234.dir\\CMakeCCompilerABI.c.obj
 /out:cmTC_90234.exe /implib:cmTC_90234.lib /pdb:cmTC_90234.pdb /version:0.0
/debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib
advapi32.lib && cd ."
         FAILED: cmTC_90234.exe
         cmd.exe /C "cd . && "C:\\Program 
Files\\CMake\\bin\\cmake.exe" -E vs_link_exe 
--intdir=CMakeFiles\\cmTC_90234.dir --rc=rc 
--mt=CMAKE_MT-NOTFOUND --manifests  -- 
C:\\PROGRA~2\\MICROS~2\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\Ho
tx64\\x64\\link.exe /nologo CMakeFiles\\cmTC_90234.dir\\CMakeCCompilerABI.c.obj
 /out:cmTC_90234.exe /implib:cmTC_90234.lib /pdb:cmTC_90234.pdb /version:0.0
/debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib
advapi32.lib && cd ."
         RC Pass 1: command "rc /fo 
CMakeFiles\\cmTC_90234.dir/manifest.res 
CMakeFiles\\cmTC_90234.dir/manifest.rc" failed (exit code 0) with 
the following output:
         The system cannot find the file specified
         ninja: build stopped: subcommand failed.

       exitCode: 1
============

It works with the MVSC 2019 generator, but I have no idea why it 
wont generate the NINJA build files. I tried running it from the 
VS Developer Command prompt, and that doesnt work either, 
different error messages, and looks like it might be trying to 
link to x86 libs instead of x64, but cant seem to figure out how 
to change that.

disclaimer: total newbie on CMAKE, build scripts, etc...
Aug 19 2023
parent reply claptrap <clap trap.com> writes:
On Saturday, 19 August 2023 at 19:47:15 UTC, claptrap wrote:
 Ok been banging my head against this for a few hours and 
 getting nowhere. Following the windows build instructions up to 
 the point of generating NINJA build files...
Ok got as far as generating NINJA build files, but now the build is failing... C:\LDCDEV\build-ldc-x64>ninja [1/104] Linking CXX executable bin\FileCheck.exe FAILED: bin/FileCheck.exe error LNK2019: unresolved external symbol __std_find_trivial_8 error LNK2001: unresolved external symbol __std_find_trivial_1 error LNK2001: unresolved external symbol __std_init_once_link_alternate_names_and_abort and others Actual output is prob 1000 lines but seems to be mostly unresolved eternal symbols, in llvm. Any ideas?
Aug 19 2023
parent reply kinke <noone nowhere.com> writes:
On Sunday, 20 August 2023 at 00:12:06 UTC, claptrap wrote:
 Ok got as far as generating NINJA build files, but now the 
 build is failing...


 C:\LDCDEV\build-ldc-x64>ninja
 [1/104] Linking CXX executable bin\FileCheck.exe
 FAILED: bin/FileCheck.exe

 error LNK2019: unresolved external symbol __std_find_trivial_8
 error LNK2001: unresolved external symbol __std_find_trivial_1
 error LNK2001: unresolved external symbol 
 __std_init_once_link_alternate_names_and_abort

 and others

 Actual output is prob 1000 lines but seems to be mostly 
 unresolved eternal symbols, in llvm.

 Any ideas?
I guess you're using a prebuilt LLVM but a non-matching Visual C++ version. Our prebuilt LLVM is built with VS 2022 and clang 15. As stated in https://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using MSVC#Building_LLVM, you'll need to build LLVM yourself in such a case.
Aug 21 2023
parent reply claptrap <clap trap.com> writes:
On Monday, 21 August 2023 at 08:15:16 UTC, kinke wrote:
 On Sunday, 20 August 2023 at 00:12:06 UTC, claptrap wrote:
 Ok got as far as generating NINJA build files, but now the 
 build is failing...


 C:\LDCDEV\build-ldc-x64>ninja
 [1/104] Linking CXX executable bin\FileCheck.exe
 FAILED: bin/FileCheck.exe

 error LNK2019: unresolved external symbol __std_find_trivial_8
 error LNK2001: unresolved external symbol __std_find_trivial_1
 error LNK2001: unresolved external symbol 
 __std_init_once_link_alternate_names_and_abort

 and others

 Actual output is prob 1000 lines but seems to be mostly 
 unresolved eternal symbols, in llvm.

 Any ideas?
I guess you're using a prebuilt LLVM but a non-matching Visual C++ version. Our prebuilt LLVM is built with VS 2022 and clang 15. As stated in https://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using MSVC#Building_LLVM, you'll need to build LLVM yourself in such a case.
Thanks, I managed to get it all to work, I had to build llvm from scratch as you suggest. There were a few other things tripping me up but I got there in the end. I just deleted everything and ran though the instructions more carefully. With what I learned from the first try it all went smoothly. Making sure everything was "run as administrator" was probably the main issue. Like for some reason if I forgot to run the shell as administrator, CMAKE would run, but it would error out on odd things. Like it would detect the compilers, but not the compiler ABI.
Aug 21 2023
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Monday, 21 August 2023 at 08:55:02 UTC, claptrap wrote:
 On Monday, 21 August 2023 at 08:15:16 UTC, kinke wrote:
 [...]
Thanks, I managed to get it all to work, I had to build llvm from scratch as you suggest. There were a few other things tripping me up but I got there in the end. I just deleted everything and ran though the instructions more carefully. With what I learned from the first try it all went smoothly. Making sure everything was "run as administrator" was probably the main issue. Like for some reason if I forgot to run the shell as administrator, CMAKE would run, but it would error out on odd things. Like it would detect the compilers, but not the compiler ABI.
You might be the only individual in the universe who have made it. Can you post some build scrips and setup for how you got everything to work?
Oct 21 2023
parent claptrap <clap trap.com> writes:
On Saturday, 21 October 2023 at 08:16:42 UTC, Imperatorn wrote:
 On Monday, 21 August 2023 at 08:55:02 UTC, claptrap wrote:
 On Monday, 21 August 2023 at 08:15:16 UTC, kinke wrote:
 [...]
Thanks, I managed to get it all to work, I had to build llvm from scratch as you suggest. There were a few other things tripping me up but I got there in the end. I just deleted everything and ran though the instructions more carefully. With what I learned from the first try it all went smoothly. Making sure everything was "run as administrator" was probably the main issue. Like for some reason if I forgot to run the shell as administrator, CMAKE would run, but it would error out on odd things. Like it would detect the compilers, but not the compiler ABI.
You might be the only individual in the universe who have made it. Can you post some build scrips and setup for how you got everything to work?
I followed the instructions to the letter, same folder names, one step at a time, from here... https://wiki.dlang.org/Building_and_hacking_LDC_on_Windows_using_MSVC I had to ensure the command prompts were always run as administrator. It gave odd error messages if I forgot to do that. I did it on a fresh install of windows 10, with a fresh install of VS2017, I literally tried to replicate everything listed in the instructions. IIRC The only thing I had to do extra was passing "-DD_COMPILER=c:\path\to\ldmd2.exe." to ninja, it's listed in the section "Building LDC" but doesn't really tell you why you might need it. I'm not 100% sure that's all there was to it but if you can't get it to work I can always have a run at it again and keep notes of exactly how I got it to work.
Nov 14 2023