zig icon indicating copy to clipboard operation
zig copied to clipboard

stage3 fails with "duplicate symbol: atexit" (windows, Visual Studio 17 2022 + cmake)

Open gglosny opened this issue 2 years ago • 1 comments

Zig Version

0.11.0

Steps to Reproduce and Observed Behavior

  1. I have built LLVM, LLD and CLANG from sources (all in version 15.0.7 with -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT)
  2. In Zig folder I have created "build-release" subfolder
  3. Run command (from VS native x64 command prompt)(MY_INSTALL_PATH is path where LLVM, LLD and CLANG are installed): cmake .. -Thost=x64 -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH=MY_INSTALL_PATH -DCMAKE_BUILD_TYPE=Release -DLLVM_CONFIG_EXE=MY_INSTALL_PATH\bin\llvm-config
  4. Build with msbuild -p:Configuration=Release INSTALL.vcxproj

This results in stage3 error:

CustomBuild:
  Building stage3
CUSTOMBUILD : error : lld-link: duplicate symbol: atexit [D:\SVN\Zig\trunk\build-release\stage3.vcxproj]
      note: defined at C:\Users\demon\AppData\Local\zig\o\209e09fb517cd144f0a09ab0d532aab0\crt2.obj
      note: defined at LIBCMT.lib(utility.obj)
CUSTOMBUILD : error : zig... [D:\SVN\Zig\trunk\build-release\stage3.vcxproj]
CUSTOMBUILD : error : The following command exited with error code 1: [D:\SVN\Zig\trunk\build-release\stage3.vcxproj]

Expected Behavior

Build without errors.

gglosny avatar Mar 12 '23 15:03 gglosny

This might be caused by a mismatch between -gnu and -msvc, check out the MSVC bootstrap script: https://github.com/ziglang/zig-bootstrap/blob/master/build.bat which might help you narrow down the issue.

kcbanner avatar Mar 12 '23 16:03 kcbanner

This might be caused by a mismatch between -gnu and -msvc, check out the MSVC bootstrap script: https://github.com/ziglang/zig-bootstrap/blob/master/build.bat which might help you narrow down the issue.

Today I finally had time to repeat build from source process according to zip-bootstrap script. I can confirm that build process finished successfully, however I still don't know reason for previous failure. Previously I've builded llvm, lld and clang separately (without -DLLVM_ENABLE_PROJECTS="lld;clang"), and when I started building zig it didn't complained about zlib, but this time I had to build zlib too. Previously I didn't set variable -DCMAKE_USER_MAKE_RULES_OVERRIDE="%ROOTDIR%/zig/cmake/c_flag_overrides.cmake" too - maybe this was the reason.

gglosny avatar Mar 22 '23 19:03 gglosny