From 9264fa6eada8f092d171f2785561936320ac5e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Tue, 17 Feb 2015 19:51:17 +0100 Subject: [PATCH] work around a recent clang change --- build.sh | 1 + patches/cctools-ld64-llvm-3.7.patch | 49 +++++++++++++++++++++++++++++ wrapper/target.cpp | 29 ++++++++++++----- wrapper/target.h | 5 +-- 4 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 patches/cctools-ld64-llvm-3.7.patch diff --git a/build.sh b/build.sh index 375b0b4..5e42408 100755 --- a/build.sh +++ b/build.sh @@ -179,6 +179,7 @@ popd &>/dev/null patch -p0 < $PATCH_DIR/cctools-ld64-1.patch patch -p0 < $PATCH_DIR/cctools-ld64-2.patch patch -p1 < $PATCH_DIR/cctools-ld64-strnlen.patch +patch -p0 < $PATCH_DIR/cctools-ld64-llvm-3.7.patch echo "" CONFFLAGS="--prefix=$TARGET_DIR --target=x86_64-apple-$TARGET" [ -n "$DISABLE_LTO_SUPPORT" ] && CONFFLAGS+=" --enable-lto=no" diff --git a/patches/cctools-ld64-llvm-3.7.patch b/patches/cctools-ld64-llvm-3.7.patch new file mode 100644 index 0000000..ae35139 --- /dev/null +++ b/patches/cctools-ld64-llvm-3.7.patch @@ -0,0 +1,49 @@ +--- configure ++++ configure +@@ -8147,6 +8147,10 @@ + $RM -r conftest* + + ++## CAVEAT EMPTOR: ++## There is no encapsulation within the following macros, do not change ++## the running order or otherwise move them around unless you know exactly ++## what you are doing... + if test -n "$compiler"; then + + lt_prog_compiler_no_builtin_flag= +@@ -16686,10 +16690,12 @@ + + if test "x$enable_lto" = "xyes"; then + for ac_prog in llvm-config \ +- llvm-config-3.6 llvm-config-3.5 llvm-config-3.4 \ +- llvm-config-3.3 llvm-config-3.2 llvm-config-3.1 \ +- llvm-config36 llvm-config35 llvm-config34 \ +- llvm-config33 llvm-config32 llvm-config31 ++ llvm-config-3.7 llvm-config-3.6 llvm-config-3.5 \ ++ llvm-config-3.4 llvm-config-3.3 llvm-config-3.2 \ ++ llvm-config-3.1 \ ++ llvm-config37 llvm-config36 llvm-config35 \ ++ llvm-config34 llvm-config33 llvm-config32 \ ++ llvm-config31 + do + # Extract the first word of "$ac_prog", so it can be a program name with args. + set dummy $ac_prog; ac_word=$2 +--- m4/llvm.m4 ++++ m4/llvm.m4 +@@ -8,10 +8,12 @@ + if test "x$enable_lto" = "xyes"; then + AC_PATH_PROGS(LLVM_CONFIG, + [llvm-config \ +- llvm-config-3.6 llvm-config-3.5 llvm-config-3.4 \ +- llvm-config-3.3 llvm-config-3.2 llvm-config-3.1 \ +- llvm-config36 llvm-config35 llvm-config34 \ +- llvm-config33 llvm-config32 llvm-config31], ++ llvm-config-3.7 llvm-config-3.6 llvm-config-3.5 \ ++ llvm-config-3.4 llvm-config-3.3 llvm-config-3.2 \ ++ llvm-config-3.1 \ ++ llvm-config37 llvm-config36 llvm-config35 \ ++ llvm-config34 llvm-config33 llvm-config32 \ ++ llvm-config31], + no) + + if test "x$LLVM_CONFIG" != "xno"; then diff --git a/wrapper/target.cpp b/wrapper/target.cpp index 7075815..6a3b5b0 100644 --- a/wrapper/target.cpp +++ b/wrapper/target.cpp @@ -246,7 +246,7 @@ const std::string Target::getFullCompilerName() const { return compiler; } -bool Target::findClangIntrinsicHeaders(std::string &path) const { +bool Target::findClangIntrinsicHeaders(std::string &path) { std::string clangbin; static std::stringstream dir; @@ -257,11 +257,13 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { if (clangbin.empty()) return false; - static ClangVersion clangversion; + static ClangVersion *clangversion; static std::string pathtmp; + clangversion = &this->clangversion; + clear(dir); - clangversion = ClangVersion(); + *clangversion = ClangVersion(); pathtmp.clear(); auto check = []()->bool { @@ -283,8 +285,8 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { file << "/xmmintrin.h"; if (fileExists(file.str())) { - if (cv > clangversion) { - clangversion = cv; + if (cv > *clangversion) { + *clangversion = cv; pathtmp.swap(intrindir); } return true; @@ -308,7 +310,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { return true; }); - return clangversion != ClangVersion(); + return *clangversion != ClangVersion(); }; dir << clangbin << "/../lib/clang"; @@ -341,7 +343,7 @@ bool Target::findClangIntrinsicHeaders(std::string &path) const { } path.swap(pathtmp); - return clangversion != ClangVersion(); + return *clangversion != ClangVersion(); } void Target::setupGCCLibs(Arch arch) { @@ -612,6 +614,19 @@ bool Target::setup() { // Use libs from './build_gcc' installation setupGCCLibs(targetarch[0]); } + +#ifndef __APPLE__ + // TODO: Need a way to distinguish between vanilla and Xcode clang + // versions. + + if (clangversion >= ClangVersion(3, 7, 0) && + !getenv("OSXCROSS_NO_DEF_SIZED_DELETE")) { + // Will run into linker errors otherwise with not so recent libc++ + // and libstdc++ versions. + if (!usegcclibs || gccversion < GCCVersion(5, 0, 0)) + fargs.push_back("-fdef-sized-delete"); + } +#endif } } else if (isGCC()) { diff --git a/wrapper/target.h b/wrapper/target.h index 828899c..ea2fe2b 100644 --- a/wrapper/target.h +++ b/wrapper/target.h @@ -134,7 +134,7 @@ struct Target { const std::string &getTriple() const { return triple; } const std::string getFullCompilerName() const; - bool findClangIntrinsicHeaders(std::string &path) const; + bool findClangIntrinsicHeaders(std::string &path); void setupGCCLibs(Arch arch); bool setup(); @@ -145,8 +145,9 @@ struct Target { std::string target; OSVersion OSNum; StdLib stdlib; - bool usegcclibs; + ClangVersion clangversion; GCCVersion gccversion; + bool usegcclibs; bool nocodegen; std::string compiler; std::string triple;