[tbb-commits] [builders/tor-browser-build] branch main updated: Bug 40605: Reworked the macOS toolchain creation.

gitolite role git at cupani.torproject.org
Wed Aug 24 13:43:40 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch main
in repository builders/tor-browser-build.

The following commit(s) were added to refs/heads/main by this push:
     new a155d0e  Bug 40605: Reworked the macOS toolchain creation.
a155d0e is described below

commit a155d0e4a249089d1fe51bcfd621b699df2bca85
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Tue Aug 16 22:03:02 2022 +0200

    Bug 40605: Reworked the macOS toolchain creation.
    
    We were compiling another Clang with the macOS toolchain, but we did not
    really need to, so I have removed that step.
    
    However, compiling compiler-rt was failing in this way, so I have
    disabled a pair of components we should not need. Probably, only the
    built-ins are actually needed.
    
    Finally, we now compile libc++ in the way LLVM currently suggests.
---
 projects/clang/build             |   2 +-
 projects/macosx-toolchain/build  | 105 +++++++++++++++++----------------------
 projects/macosx-toolchain/config |   2 -
 3 files changed, 47 insertions(+), 62 deletions(-)

diff --git a/projects/clang/build b/projects/clang/build
index 48cddec..8449070 100644
--- a/projects/clang/build
+++ b/projects/clang/build
@@ -25,7 +25,7 @@ mkdir build
 cd build
 cmake ../llvm -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$distdir \
                                   -DCMAKE_BUILD_TYPE=Release \
-            [% IF c("var/android") -%]
+            [% IF c("var/android") || c("var/osx") -%]
                                   -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
             [% END -%]
             [% IF c("var/rlbox") -%]-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly[% END %] \
diff --git a/projects/macosx-toolchain/build b/projects/macosx-toolchain/build
index c4d1937..228d02d 100644
--- a/projects/macosx-toolchain/build
+++ b/projects/macosx-toolchain/build
@@ -5,78 +5,77 @@ mkdir $builddir
 distdir=/var/tmp/dist/[% project %]
 mkdir -p "$distdir"
 tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %]
-tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %]
-tar -C /var/tmp/dist -xf [% c('input_files_by_name/clang') %]
+tar -C $distdir -xf [% c('input_files_by_name/clang') %]
 tar -C $distdir -xf [% c('input_files_by_name/SDK') %]
 tar -C $distdir -xf [% c('input_files_by_name/cctools') %]
 tar -C $builddir -xf [% c('input_files_by_name/llvm-project') %]
 
 arch=x86_64
-clangdir=/var/tmp/dist/clang/bin
+clangdir=$distdir/clang/bin
 cctoolsdir=$distdir/cctools/bin
 sysrootdir=$distdir/MacOSX[% c("version") %].sdk/
 target=x86_64-apple-darwin
 # We still need to put the cctoolsdir on the path. That's because of `lipo`. See
 # the respective comment in the cctools build script.
-export PATH="/var/tmp/dist/ninja:/var/tmp/dist/cmake/bin:$cctoolsdir:$PATH"
+export PATH="/var/tmp/dist/cmake/bin:$cctoolsdir:$PATH"
 export MACOSX_DEPLOYMENT_TARGET=[% c("var/macosx_deployment_target") %]
-export MACH_USE_SYSTEM_PYTHON=1
 
 cd $builddir/clang-source
 patch -p1 < $rootdir/compiler-rt-cross-compile.patch
 patch -p1 < $rootdir/compiler-rt-no-codesign.patch
 cd ..
-mkdir build_clang
-pushd build_clang
-# We follow quite closely Mozilla's build/build-clang/build-clang.py with the
-# clang-macosx64.json flavor.
-cmake -GNinja \
+
+mkdir build_compiler_rt
+cd build_compiler_rt
+
+# And we build compiler-rt by following taskcluster/scripts/misc/build-compiler-rt.sh.
+cmake -G "Unix Makefiles" \
       -DCMAKE_C_COMPILER=$clangdir/clang \
       -DCMAKE_CXX_COMPILER=$clangdir/clang++ \
-      -DCMAKE_ASM_COMPILER=$clangdir/clang \
-      -DCMAKE_LINKER=$clangdir/clang \
-      -DCMAKE_AR=$cctoolsdir/$target-ar \
+      -DCMAKE_C_COMPILER_TARGET=$target \
+      -DCMAKE_CXX_COMPILER_TARGET=$target \
+      -DCMAKE_ASM_COMPILER_TARGET=$target \
+      -DCMAKE_AR=$clangdir/llvm-ar \
+      -DCMAKE_RANLIB=$clangdir/llvm-ranlib \
       -DCMAKE_C_FLAGS="[% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
       -DCMAKE_CXX_FLAGS="-stdlib=libc++ [% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
       -DCMAKE_ASM_FLAGS="[% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
       -DCMAKE_EXE_LINKER_FLAGS="[% c('var/LDFLAGS') %]" \
       -DCMAKE_SHARED_LINKER_FLAGS="[% c('var/LDFLAGS') %]" \
       -DCMAKE_BUILD_TYPE=Release \
-      -DCMAKE_INSTALL_PREFIX=$distdir/clang \
-      -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" \
       -DLLVM_ENABLE_ASSERTIONS=OFF \
-      -DPYTHON_EXECUTABLE=/usr/bin/python3 \
-      -DLLVM_TOOL_LIBCXX_BUILD=ON \
-      -DLLVM_ENABLE_BINDINGS=OFF \
-      -DLLVM_ENABLE_LIBXML2=FORCE_ON \
-      -DLLVM_LINK_LLVM_DYLIB=ON \
-      -DCMAKE_RANLIB=$cctoolsdir/$target-ranlib \
-      -DCMAKE_LIBTOOL=$cctoolsdir/$target-libtool \
+      -DCMAKE_INSTALL_PREFIX=$distdir/clang/lib/clang/[% pc("clang", "version") %]/ \
+      -DLLVM_CONFIG_PATH=$clangdir/llvm-config \
+      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
+      -DCOMPILER_RT_ENABLE_IOS=OFF \
+      -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
+      -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
+      -DCOMPILER_RT_ENABLE_TVOS=OFF \
+      -DCOMPILER_RT_ENABLE_WATCHOS=OFF \
+      -DCOMPILER_RT_BUILD_XRAY=OFF \
+      -DCMAKE_LINKER=$cctoolsdir/$target-ld \
+      -DCMAKE_LIPO=$cctoolsdir/lipo \
       -DCMAKE_SYSTEM_NAME=Darwin \
       -DCMAKE_SYSTEM_VERSION=$MACOSX_DEPLOYMENT_TARGET \
-      -DLLVM_ENABLE_THREADS=OFF \
-      -DCOMPILER_RT_BUILD_XRAY=OFF \
-      -DLIBCXXABI_LIBCXX_INCLUDES=$builddir/clang-source/projects/libcxx/include \
+      -DDARWIN_macosx_OVERRIDE_SDK_VERSION=$MACOSX_DEPLOYMENT_TARGET \
+      -DDARWIN_osx_ARCHS=$arch \
+      -DDARWIN_osx_SYSROOT=$sysrootdir \
+      -DDARWIN_osx_BUILTIN_ARCHS=$arch \
       -DCMAKE_OSX_SYSROOT=$sysrootdir \
       -DCMAKE_FIND_ROOT_PATH=$sysrootdir \
       -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
       -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
       -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-      -DCMAKE_MACOSX_RPATH=ON \
-      -DCMAKE_OSX_ARCHITECTURES=$arch \
-      -DDARWIN_macosx_OVERRIDE_SDK_VERSION=$MACOSX_DEPLOYMENT_TARGET \
-      -DDARWIN_osx_ARCHS=$arch \
-      -DDARWIN_osx_SYSROOT=$sysrootdir \
-      -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin $builddir/clang-source/llvm
+      -DDARWIN_osx_BUILTIN_ARCHS=$arch \
+      $builddir/clang-source/compiler-rt
 
-ninja install -v
+make -j[% c("num_procs") %]
+make install
 
-popd
-mkdir build_compiler_rt
-pushd build_compiler_rt
+cd $builddir/clang-source
 
-# And we build compiler-rt by following taskcluster/scripts/misc/build-compiler-rt.sh.
-cmake -GNinja \
+cmake -G "Unix Makefiles" -S runtimes -B build \
+      -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
       -DCMAKE_C_COMPILER=$clangdir/clang \
       -DCMAKE_CXX_COMPILER=$clangdir/clang++ \
       -DCMAKE_C_COMPILER_TARGET=$target \
@@ -84,23 +83,19 @@ cmake -GNinja \
       -DCMAKE_ASM_COMPILER_TARGET=$target \
       -DCMAKE_AR=$clangdir/llvm-ar \
       -DCMAKE_RANLIB=$clangdir/llvm-ranlib \
-      -DCMAKE_C_FLAGS="[% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
-      -DCMAKE_CXX_FLAGS="-stdlib=libc++ [% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
-      -DCMAKE_ASM_FLAGS="[% c('var/FLAGS') %] -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
-      -DCMAKE_EXE_LINKER_FLAGS="[% c('var/LDFLAGS') %]" \
-      -DCMAKE_SHARED_LINKER_FLAGS="[% c('var/LDFLAGS') %]" \
+      -DCMAKE_C_FLAGS="-target x86_64-apple-darwin -B $cctoolsdir -isysroot $sysrootdir -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
+      -DCMAKE_CXX_FLAGS="-stdlib=libc++ -target x86_64-apple-darwin -B $cctoolsdir -isysroot $sysrootdir -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
+      -DCMAKE_ASM_FLAGS="-target x86_64-apple-darwin -B $cctoolsdir -isysroot $sysrootdir -I$sysrootdir/usr/include -iframework $sysrootdir/System/Library/Frameworks" \
+      -DCMAKE_EXE_LINKER_FLAGS="-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie" \
+      -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-syslibroot,$sysrootdir -Wl,-dead_strip -Wl,-pie" \
       -DCMAKE_BUILD_TYPE=Release \
       -DLLVM_ENABLE_ASSERTIONS=OFF \
-      -DCMAKE_INSTALL_PREFIX=$distdir/clang/lib/clang/[% pc("clang", "version") %]/ \
-      -DLLVM_CONFIG_PATH=$clangdir/llvm-config \
-      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
+      -DCMAKE_INSTALL_PREFIX=$distdir/clang \
       -DCMAKE_LINKER=$cctoolsdir/$target-ld \
-      -DCMAKE_LIPO=$cctoolsdir/lipo \
       -DCMAKE_SYSTEM_NAME=Darwin \
       -DCMAKE_SYSTEM_VERSION=$MACOSX_DEPLOYMENT_TARGET \
       -DDARWIN_macosx_OVERRIDE_SDK_VERSION=$MACOSX_DEPLOYMENT_TARGET \
       -DDARWIN_osx_ARCHS=$arch \
-      -DDARWIN_osx_SYSROOT=$sysrootdir \
       -DDARWIN_osx_BUILTIN_ARCHS=$arch \
       -DCMAKE_OSX_SYSROOT=$sysrootdir \
       -DCMAKE_FIND_ROOT_PATH=$sysrootdir \
@@ -108,20 +103,12 @@ cmake -GNinja \
       -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
       -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
       -DDARWIN_osx_BUILTIN_ARCHS=$arch \
-      $builddir/clang-source/compiler-rt
-
-ninja install -v
 
-# We now have a native macosx64 toolchain.
-# What we want is a native linux64 toolchain which can target macosx64.
-# Overlay the linux64 toolchain that we used for this build. Note: we don't do
-# any ASan builds for macOS (yet). Once we do that we need to preserve at least
-# `llvm-symbolizer` as that one seems to get shipped with sanitizer builds (at
-# least that's what Mozilla claims).
-cd $distdir
-cp --remove-destination -lr /var/tmp/dist/clang/* clang/
+cd build
+make -j[% c("num_procs") %]
+make install
 
-cd cctools/bin
+cd $distdir/cctools/bin
 ln -s ../../clang/bin/clang x86_64-apple-darwin-clang
 ln -s ../../clang/bin/clang++ x86_64-apple-darwin-clang++
 
diff --git a/projects/macosx-toolchain/config b/projects/macosx-toolchain/config
index 0afe1d9..cd66b0f 100644
--- a/projects/macosx-toolchain/config
+++ b/projects/macosx-toolchain/config
@@ -24,8 +24,6 @@ input_files:
     project: cctools
   - name: cmake
     project: cmake
-  - name: ninja
-    project: ninja
   # Instructions on how to create the SDK tarball can be found at:
   # build/macosx/cross-mozconfig.common
   - name: SDK

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list