Bug 1262735 - Separate compiler and flags when passing them to CMake. r=ehsan
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 07 Apr 2016 15:04:13 +0900
changeset 330792 99162c94067e9abbdc93770938e9a971cb9ad3de
parent 330791 55b2f91e705dc6a6938b3c53b7981fca537b19e1
child 330793 aacb077966095faae51be77616408d1fa9073a5f
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1262735, 1042132
milestone48.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 1262735 - Separate compiler and flags when passing them to CMake. r=ehsan When passing -DCMAKE_C_COMPILER="gcc -flags" to CMake, ninja then tries to literally call "gcc -flags", not "gcc" "-flags", and a "gcc -flags" file obviously doesn't exist, so the build fails. This fixes a regression from bug 1042132. Hopefully, this also doesn't regress bug 1042132 itself.
build/build-clang/build-clang.py
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -191,18 +191,20 @@ def build_one_stage_aux(cc, cxx, src_dir
     build_dir = stage_dir + "/build"
     inst_dir = stage_dir + "/clang"
 
     run_cmake = True
     if os.path.exists(build_dir + "/build.ninja"):
         run_cmake = False
 
     cmake_args = ["-GNinja",
-                  "-DCMAKE_C_COMPILER=%s" % cc,
-                  "-DCMAKE_CXX_COMPILER=%s" % cxx,
+                  "-DCMAKE_C_COMPILER=%s" % cc[0],
+                  "-DCMAKE_CXX_COMPILER=%s" % cxx[0],
+                  "-DCMAKE_C_FLAGS=%s" % ' '.join(cc[1:]),
+                  "-DCMAKE_CXX_FLAGS=%s" % ' '.join(cxx[1:]),
                   "-DCMAKE_BUILD_TYPE=%s" % build_type,
                   "-DLLVM_TARGETS_TO_BUILD=X86;ARM",
                   "-DLLVM_ENABLE_ASSERTIONS=%s" % ("ON" if assertions else "OFF"),
                   "-DPYTHON_EXECUTABLE=%s" % python_path,
                   "-DCMAKE_INSTALL_PREFIX=%s" % inst_dir,
                   "-DLLVM_TOOL_LIBCXX_BUILD=%s" % ("ON" if build_libcxx else "OFF"),
                   "-DLIBCXX_LIBCPPABI_VERSION=\"\"",
                   src_dir];
@@ -338,68 +340,68 @@ if __name__ == "__main__":
         os.makedirs(build_dir)
 
     stage1_dir = build_dir + '/stage1'
     stage1_inst_dir = stage1_dir + '/clang'
 
     final_stage_dir = stage1_dir
 
     if is_darwin():
-        extra_cflags = ""
-        extra_cxxflags = "-stdlib=libc++"
-        extra_cflags2 = ""
-        extra_cxxflags2 = "-stdlib=libc++"
+        extra_cflags = []
+        extra_cxxflags = ["-stdlib=libc++"]
+        extra_cflags2 = []
+        extra_cxxflags2 = ["-stdlib=libc++"]
     elif is_linux():
-        extra_cflags = "-static-libgcc"
-        extra_cxxflags = "-static-libgcc -static-libstdc++"
-        extra_cflags2 = "-fPIC --gcc-toolchain=%s" % gcc_dir
-        extra_cxxflags2 = "-fPIC --gcc-toolchain=%s" % gcc_dir
+        extra_cflags = ["-static-libgcc"]
+        extra_cxxflags = ["-static-libgcc", "-static-libstdc++"]
+        extra_cflags2 = ["-fPIC", "--gcc-toolchain=%s" % gcc_dir]
+        extra_cxxflags2 = ["-fPIC", "--gcc-toolchain=%s" % gcc_dir]
 
         if os.environ.has_key('LD_LIBRARY_PATH'):
             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
     elif is_windows():
-        extra_cflags = ""
-        extra_cxxflags = ""
-        extra_cflags2 = ""
-        extra_cxxflags2 = ""
+        extra_cflags = []
+        extra_cxxflags = []
+        extra_cflags2 = []
+        extra_cxxflags2 = []
 
     build_one_stage(
-        cc + " %s" % extra_cflags,
-        cxx + " %s" % extra_cxxflags,
+        [cc] + extra_cflags,
+        [cxx] + extra_cxxflags,
         llvm_source_dir, stage1_dir, build_libcxx,
         build_type, assertions, python_path)
 
     if stages > 1:
         stage2_dir = build_dir + '/stage2'
         stage2_inst_dir = stage2_dir + '/clang'
         final_stage_dir = stage2_dir
         build_one_stage(
-            stage1_inst_dir + "/bin/%s%s %s" %
-                (cc_name, exe_ext, extra_cflags2),
-            stage1_inst_dir + "/bin/%s%s %s" %
-                (cxx_name, exe_ext, extra_cxxflags2),
+            [stage1_inst_dir + "/bin/%s%s" %
+                (cc_name, exe_ext)] + extra_cflags2,
+            [stage1_inst_dir + "/bin/%s%s" %
+                (cxx_name, exe_ext)] + extra_cxxflags2,
             llvm_source_dir, stage2_dir, build_libcxx,
             build_type, assertions, python_path)
 
         if stages > 2:
             stage3_dir = build_dir + '/stage3'
             final_stage_dir = stage3_dir
             build_one_stage(
-                stage2_inst_dir + "/bin/%s%s %s" %
-                    (cc_name, exe_ext, extra_cflags2),
-                stage2_inst_dir + "/bin/%s%s %s" %
-                    (cxx_name, exe_ext, extra_cxxflags2),
+                [stage2_inst_dir + "/bin/%s%s" %
+                    (cc_name, exe_ext)] + extra_cflags2,
+                [stage2_inst_dir + "/bin/%s%s" %
+                    (cxx_name, exe_ext)] + extra_cxxflags2,
                 llvm_source_dir, stage3_dir, build_libcxx,
                 build_type, assertions, python_path)
 
     if is_linux():
         final_stage_inst_dir = final_stage_dir + '/clang'
         build_and_use_libgcc(
-            {"CC": cc + " %s" % extra_cflags,
-             "CXX": cxx + " %s" % extra_cxxflags},
+            {"CC": cc + " %s" % ' '.join(extra_cflags),
+             "CXX": cxx + " %s" % ' '.join(extra_cxxflags)},
             final_stage_inst_dir)
 
     if is_darwin() or is_windows():
         build_tar_package("tar", "clang.tar.bz2", final_stage_dir, "clang")
     else:
         build_tar_package("tar", "clang.tar.xz", final_stage_dir, "clang")