llvm: Don't use libunwind on FreeBSD
Native builds on nixpkgs FreeBSD always use llvm's libc++ as the C++ standard library, with libcxxrt and "libgcc" from the FreeBSD tree providing lower level ABI functions. However, the cross LLVM stdenv assumed that we wanted libunwind instead of libgcc. As libgcc headers are already in FreeBSD's libc, some C++ functions failed with duplicate header errors. Disable all references to libunwind in libcxx on FreeBSD and the LLVM cross stdenvs for FreeBSD.
This commit is contained in:
parent
11eb12b0ca
commit
f76271c4df
@ -229,7 +229,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -238,12 +238,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
@ -271,7 +271,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -280,12 +280,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
@ -272,7 +272,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -281,12 +281,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
@ -256,7 +256,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -265,12 +265,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
@ -255,7 +255,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -264,12 +264,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
@ -83,9 +83,13 @@ let
|
||||
"-DLIBCXX_HAS_MUSL_LIBC=1"
|
||||
] ++ lib.optionals (lib.versionAtLeast release_version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
|
||||
"-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
|
||||
] ++ lib.optionals (lib.versionAtLeast release_version "18" && stdenv.hostPlatform.isFreeBSD) [
|
||||
# Name and documentation claim this is for libc++abi, but its man effect is adding `-lunwind`
|
||||
# to the libc++.so linker script. We want FreeBSD's so-called libgcc instead of libunwind.
|
||||
"-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
|
||||
] ++ lib.optionals useLLVM [
|
||||
"-DLIBCXX_USE_COMPILER_RT=ON"
|
||||
] ++ lib.optionals (useLLVM && lib.versionAtLeast release_version "16") [
|
||||
] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isFreeBSD && lib.versionAtLeast release_version "16") [
|
||||
"-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
|
||||
] ++ lib.optionals stdenv.hostPlatform.isWasm [
|
||||
"-DLIBCXX_ENABLE_THREADS=OFF"
|
||||
@ -122,7 +126,7 @@ stdenv.mkDerivation (rec {
|
||||
++ lib.optional (cxxabi != null) lndir;
|
||||
|
||||
buildInputs = [ cxxabi ]
|
||||
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
|
||||
++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm && !stdenv.hostPlatform.isFreeBSD) [ libunwind ];
|
||||
|
||||
# libc++.so is a linker script which expands to multiple libraries,
|
||||
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
|
||||
|
@ -260,7 +260,7 @@ in let
|
||||
bintools = bintools';
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
] ++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
@ -269,12 +269,12 @@ in let
|
||||
"-Wno-unused-command-line-argument"
|
||||
"-B${targetLlvmLibraries.compiler-rt}/lib"
|
||||
]
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
|
||||
++ lib.optional (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) "--unwindlib=libunwind"
|
||||
++ lib.optional
|
||||
(!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
|
||||
(!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false)
|
||||
"-lunwind"
|
||||
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
|
||||
};
|
||||
|
||||
clangNoLibcxx = wrapCCWith rec {
|
||||
|
Loading…
Reference in New Issue
Block a user