Closed Vexu closed 1 year ago
libstdc++ sounds like gcc which should not be relevant once LLVM is being rebuilt with zig.
I'm able to reproduce this, looking into it now.
the cmake check looks like this:
check_cxx_source_compiles("
#include <iosfwd>
#if defined(__GLIBCXX__)
#if __GLIBCXX__ < ${GCC_MIN_DATE}
#error Unsupported libstdc++ version
#endif
#endif
#if defined(__GLIBCXX__)
extern const char _ZNKSt17bad_function_call4whatEv[];
const char *chk = _ZNKSt17bad_function_call4whatEv;
#else
const char *chk = \"\";
#endif
int main() { ++chk; return 0; }
"
LLVM_LIBSTDCXX_MIN)
if(NOT LLVM_LIBSTDCXX_MIN)
message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
endif()
When I do this manually, it compiles successfully:
#include <iosfwd>
#if defined(__GLIBCXX__)
#if __GLIBCXX__ < 20150422
#error Unsupported libstdc++ version
#endif
#endif
#if defined(__GLIBCXX__)
extern const char _ZNKSt17bad_function_call4whatEv[];
const char *chk = _ZNKSt17bad_function_call4whatEv;
#else
const char *chk = "";
#endif
int main() { ++chk; return 0; }
$ ~/dev/zig-bootstrap/out/host/bin/zig c++ -o test test.cpp -std=c++0x -fno-sanitize=all -s -target x86_64-windows-gnu -mcpu=baseline
$ echo $?
0
Unclear why cmake is getting a non-zero exit code when it does this check.
Managed to narrow the problem down:
andy@ark ~/d/b/o/b/C/CMakeTmp (master)> ../../../host/bin/zig c++ -fno-sanitize=all -s -target x86_64-windows-gnu -mcpu=baseline -std=c++0x -static -Wl,--whole-archive CMakeFiles/cmTC_9bcc2.dir/objects.a -Wl,--no-whole-archive -o cmTC_9bcc2.exe -Wl,--out-implib,libcmTC_9bcc2.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles/cmTC_9bcc2.dir/linklibs.rsp
error: unable to create compilation: UnableToStaticLink
andy@ark ~/d/b/o/b/C/CMakeTmp (master) [1]> cat CMakeFiles/cmTC_9bcc2.dir/linklibs.rsp
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
Perhaps a regression after upgrading mingw version.
Regression caused by https://github.com/ziglang/zig/commit/6af0eeb58d1d220d407ce4c463eaeb25b35f2761
I'm testing this patch.
--- a/zig/src/main.zig
+++ b/zig/src/main.zig
@@ -1653,8 +1653,14 @@ fn buildOutputType(
};
}
},
- .dynamic => link_mode = .Dynamic,
- .static => link_mode = .Static,
+ .dynamic => switch (output_mode) {
+ .Lib => link_mode = .Dynamic,
+ .Obj, .Exe => force_static_libs = false,
+ },
+ .static => switch (output_mode) {
+ .Lib => link_mode = .Static,
+ .Obj, .Exe => force_static_libs = true,
+ },
}
}
// Parse linker args.
@Vexu do you have any ideas how the -static
flag is supposed to work for C compilers when targeting Windows?
@Vexu do you have any ideas how the
-static
flag is supposed to work for C compilers when targeting Windows?
No but I can look into it.
Steps to reproduce
./build -j8 x86_64-windows-gnu baseline
I did the update by
rsync
ing the various folders insidezig/
, it seems correct but I might be wrong.