Bug 1485503 - Avoid ld64 merging static and non-static data with the same name during ThinLTO. r=dmajor
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 23 Aug 2018 07:05:15 +0900
changeset 481509 4017bcbb799df8fc3cb8202969a1c85e5dc1cf94
parent 481508 59c38e3958fe43fa2c968f729e61f4c41815f47e
child 481510 4239ad0cf14733e735a63c3e6677e37b41fe914f
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersdmajor
bugs1485503, 1478917
milestone63.0a1
Bug 1485503 - Avoid ld64 merging static and non-static data with the same name during ThinLTO. r=dmajor When different translation units contain the same symbol name, all static, but one of them non-static, ld64 wrongfully link the references to the static data with the non-static data, or vice versa. With libaom and libvpx sharing data structures with the same name but different contents, that leads to interesting failures/crashes at runtime. This was apparently fixed in Apple ld64 from Xcode 9, but the last open sourced version is the one from Xcode 8, so I ended up digging in the ld64 source code and fixed the issue. This work was merged to cctools-port upstream in https://github.com/tpoechtrager/cctools-port/pull/59. For the same reason as invoked in bug 1478917, though, updating to cctools-port master is more involved than just changing a commit sha1 (as it requires building apple-libtapi, which in turn builds parts of LLVM, which should probably be avoided), so just cherry-pick the fix.
taskcluster/scripts/misc/build-cctools-port-macosx.sh
taskcluster/scripts/misc/build-cctools-port.sh
--- a/taskcluster/scripts/misc/build-cctools-port-macosx.sh
+++ b/taskcluster/scripts/misc/build-cctools-port-macosx.sh
@@ -21,18 +21,19 @@ MACOSX_SDK_DIR=$WORKSPACE/build/src/MacO
 TARGET_TRIPLE=x86_64-apple-darwin11
 
 # Create our directories
 mkdir -p $CROSSTOOLS_BUILD_DIR
 
 git clone --no-checkout $CROSSTOOL_PORT_REPOSITORY $CROSSTOOLS_SOURCE_DIR
 cd $CROSSTOOLS_SOURCE_DIR
 git checkout $CROSSTOOL_PORT_REV
-# Cherry pick a fix for LTO.
+# Cherry pick two fixes for LTO.
 git cherry-pick -n 82381f5038a340025ae145745ae5b325cd1b749a
+git cherry-pick -n 328c7371008a854af30823adcd4ec1e763054a1d
 echo "Building from commit hash `git rev-parse $CROSSTOOL_PORT_REV`..."
 
 # Fetch clang from tooltool
 cd $WORKSPACE/build/src
 . taskcluster/scripts/misc/tooltool-download.sh
 
 # Configure crosstools-port
 cd $CROSSTOOLS_CCTOOLS_DIR
--- a/taskcluster/scripts/misc/build-cctools-port.sh
+++ b/taskcluster/scripts/misc/build-cctools-port.sh
@@ -17,18 +17,19 @@ CROSSTOOLS_BUILD_DIR=$WORKSPACE/cctools
 CLANG_DIR=$WORKSPACE/build/src/clang
 
 # Create our directories
 mkdir -p $CROSSTOOLS_BUILD_DIR
 
 git clone --no-checkout $CROSSTOOL_PORT_REPOSITORY $CROSSTOOLS_SOURCE_DIR
 cd $CROSSTOOLS_SOURCE_DIR
 git checkout $CROSSTOOL_PORT_REV
-# Cherry pick a fix for LTO.
+# Cherry pick two fixes for LTO.
 git cherry-pick -n 82381f5038a340025ae145745ae5b325cd1b749a
+git cherry-pick -n 328c7371008a854af30823adcd4ec1e763054a1d
 echo "Building from commit hash `git rev-parse $CROSSTOOL_PORT_REV`..."
 
 # Fetch clang from tooltool
 cd $WORKSPACE/build/src
 . taskcluster/scripts/misc/tooltool-download.sh
 
 # Configure crosstools-port
 cd $CROSSTOOLS_CCTOOLS_DIR