Bug 1451104 - part 2 - force clang to always pick up its local GCC headers and libraries; r=glandium
☠☠ backed out by dcfd01a3010b ☠ ☠
authorNathan Froyd <froydnj@mozilla.com>
Fri, 20 Jul 2018 16:22:26 -0400
changeset 482719 b4ebc9a500f40bdac529378e6cc9f9922076e5c4
parent 482718 b93c29157feb5f14b7964b7f83ca88560dc508aa
child 482720 47405e33747c180dadbe99e4efcd879120c71c20
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1451104
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451104 - part 2 - force clang to always pick up its local GCC headers and libraries; r=glandium We want our clang bootstrap to use the GCC headers we're building with, not whatever sysroot it happens to find on the server we're building on. The -gcc-toolchain argument we specify when building clang will also be picked up by llvm-config, so we need to strip it out when building the plugin. Otherwise, we will get peculiar failures about not being able to find C++ header files.
build/autoconf/clang-plugin.m4
build/build-clang/build-clang.py
--- a/build/autoconf/clang-plugin.m4
+++ b/build/autoconf/clang-plugin.m4
@@ -31,17 +31,21 @@ if test -n "$ENABLE_CLANG_PLUGIN"; then
     AC_MSG_RESULT([$LLVMCONFIG])
 
     if test -z "$LLVMCONFIG"; then
         AC_MSG_ERROR([Cannot find an llvm-config binary for building a clang plugin])
     fi
     dnl For some reason the llvm-config downloaded from clang.llvm.org for clang3_8
     dnl produces a -isysroot flag for a sysroot which might not ship when passed
     dnl --cxxflags. We use sed to remove this argument so that builds work on OSX
-    LLVM_CXXFLAGS=`$LLVMCONFIG --cxxflags | sed -e 's/-isysroot [[^ ]]*//'`
+    dnl
+    dnl For a similar reason, we remove any -gcc-toolchain arguments, since the
+    dnl directories specified by such arguments might not exist on the current
+    dnl machine.
+    LLVM_CXXFLAGS=`$LLVMCONFIG --cxxflags | sed -e 's/-isysroot [[^ ]]*//' -e 's/-gcc-toolchain [[^ ]]*//'`
 
     LLVM_LDFLAGS=`$LLVMCONFIG --ldflags | tr '\n' ' '`
 
     if test "${HOST_OS_ARCH}" = "Darwin"; then
         dnl We need to make sure that we use the symbols coming from the clang
         dnl binary. In order to do this, we need to pass -flat_namespace and
         dnl -undefined suppress to the linker. This makes sure that we link the
         dnl symbols into the flat namespace provided by clang, and thus get
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -520,19 +520,25 @@ if __name__ == "__main__":
         extra_cxxflags = ["-stdlib=libc++"]
         extra_cflags2 = []
         extra_cxxflags2 = ["-stdlib=libc++"]
         extra_asmflags = []
         extra_ldflags = []
     elif is_linux():
         extra_cflags = ["-static-libgcc"]
         extra_cxxflags = ["-static-libgcc", "-static-libstdc++"]
-        extra_cflags2 = ["-fPIC"]
+        # When building stage2 and stage3, we want the newly-built clang to pick
+        # up whatever headers were installed from the gcc we used to build stage1,
+        # always, rather than the system headers.  Providing -gcc-toolchain
+        # encourages clang to do that.
+        extra_cflags2 = ["-fPIC",
+                         '-gcc-toolchain', stage1_inst_dir]
         # Silence clang's warnings about arguments not being used in compilation.
-        extra_cxxflags2 = ["-fPIC", '-Qunused-arguments', "-static-libstdc++"]
+        extra_cxxflags2 = ["-fPIC", '-Qunused-arguments', "-static-libstdc++",
+                           '-gcc-toolchain', stage1_inst_dir]
         extra_asmflags = []
         extra_ldflags = []
 
         if 'LD_LIBRARY_PATH' in os.environ:
             os.environ['LD_LIBRARY_PATH'] = ('%s/lib64/:%s' %
                                              (gcc_dir, os.environ['LD_LIBRARY_PATH']))
         else:
             os.environ['LD_LIBRARY_PATH'] = '%s/lib64/' % gcc_dir