summaryrefslogtreecommitdiffstats
path: root/build/macosx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/macosx/cross-mozconfig.common43
-rwxr-xr-xbuild/macosx/llvm-dsymutil75
-rw-r--r--build/macosx/local-mozconfig.common28
-rw-r--r--build/macosx/mozconfig.common15
-rw-r--r--build/macosx/permissions/chown_revert.c18
-rw-r--r--build/macosx/permissions/chown_root.c12
6 files changed, 191 insertions, 0 deletions
diff --git a/build/macosx/cross-mozconfig.common b/build/macosx/cross-mozconfig.common
new file mode 100644
index 0000000000..5e9902f7af
--- /dev/null
+++ b/build/macosx/cross-mozconfig.common
@@ -0,0 +1,43 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+. "$topsrcdir/build/mozconfig.common"
+
+# cctools for ld, ar, and other related tools ; dsymutil for rust.
+mk_add_options "export PATH=$MOZ_FETCHES_DIR/cctools/bin:$MOZ_FETCHES_DIR/binutils/bin:$MOZ_FETCHES_DIR/llvm-dsymutil/bin:$PATH"
+
+# dsymutil needs a libstdc++ more recent than what's on the system.
+mk_add_options "export LD_LIBRARY_PATH=$MOZ_FETCHES_DIR/clang/lib"
+
+# This SDK was copied from a local XCode install and uploaded to tooltool.
+# Generate the tarball by running this command with the proper SDK version:
+# sdk_path=$(xcrun --sdk macosx10.12 --show-sdk-path)
+# tar -C $(dirname ${sdk_path}) -cHjf /tmp/$(basename ${sdk_path}).tar.bz2 $(basename ${sdk_path})
+# Upload the resulting tarball from /tmp to tooltool, and change the entry in
+# `browser/config/tooltool-manifests/macosx64/cross-releng.manifest`.
+CROSS_SYSROOT=$topsrcdir/MacOSX10.12.sdk
+
+export CFLAGS="$CFLAGS -fcrash-diagnostics-dir=${UPLOAD_PATH}"
+export CXXFLAGS="$CXXFLAGS -fcrash-diagnostics-dir=${UPLOAD_PATH}"
+export DSYMUTIL=$topsrcdir/build/macosx/llvm-dsymutil
+mk_add_options "export REAL_DSYMUTIL=$MOZ_FETCHES_DIR/llvm-dsymutil/bin/dsymutil"
+export MKFSHFS=$MOZ_FETCHES_DIR/hfsplus-tools/newfs_hfs
+export DMG_TOOL=$MOZ_FETCHES_DIR/dmg/dmg
+export HFS_TOOL=$MOZ_FETCHES_DIR/dmg/hfsplus
+
+export HOST_CFLAGS="-g"
+export HOST_CXXFLAGS="-g"
+export HOST_LDFLAGS="-g"
+
+ac_add_options --target=x86_64-apple-darwin
+export MACOS_SDK_DIR=$CROSS_SYSROOT
+
+if [ "x$MOZ_PKG_SPECIAL" != "xasan" -a -z "$MOZ_AUTOMATION_ARTIFACT_BUILDS" ]; then
+ # Enable static analysis checks by default on OSX cross builds.
+ # Exception is ASan, where this breaks.
+ # The option is not valid on artifact builds, so don't add it there either.
+ ac_add_options --enable-clang-plugin
+fi
+
+unset MOZ_STDCXX_COMPAT
diff --git a/build/macosx/llvm-dsymutil b/build/macosx/llvm-dsymutil
new file mode 100755
index 0000000000..2deb78f4b6
--- /dev/null
+++ b/build/macosx/llvm-dsymutil
@@ -0,0 +1,75 @@
+#!/bin/sh
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"$REAL_DSYMUTIL" "$@"
+ret=$?
+if [ $ret -ne 139 ]; then
+ exit $ret
+fi
+
+echo "$REAL_DSYMUTIL crashed. Trying to get a reduced testcase." >&2
+tmpdir=$(mktemp -d)
+trap "rm -rf $tmpdir" EXIT
+
+# Get the library file name from the command line arguments. We assume
+# it's the last argument that doesn't start with a dash.
+for arg in "$@"; do
+ case "$arg" in
+ -*)
+ ;;
+ *)
+ lib="$arg"
+ ;;
+ esac
+done
+
+last_obj=$("$REAL_DSYMUTIL" --verbose "$@" 2> /dev/null | sed -n "/trying to open/s/trying to open '\(.*\)'/\1/p" | tail -1)
+
+case "$last_obj" in
+"")
+ echo "Could not produce a reduced testcase. Aborting." >&2
+ # Ideally, we'd produce an archive with every .o and .a involved, but so
+ # far, this case has never happened, so, meh.
+ exit 139
+ ;;
+*.a\(*.o\))
+ # The crash likely happened while reading one particular object in a library.
+ # Create a new library with just that one object.
+ archive=$(readlink -f "${last_obj%(*}")
+ obj="${last_obj#*.a(}"
+ obj="${obj%)}"
+ (cd "$tmpdir"; ar x "$archive" "$obj")
+ mkdir -p $tmpdir/crasher/$(dirname "$archive")
+ (cd "$tmpdir"; ar cr "$tmpdir/crasher/$archive" "$obj")
+ rm "$tmpdir/$obj"
+ ;;
+*)
+ # The crash likely happened while reading one particular object.
+ obj=$(readlink -f "$last_obj")
+ mkdir -p "$tmpdir/crasher/$(dirname "$obj")"
+ cp "$obj" "$tmpdir/crasher/$obj"
+ ;;
+esac
+cp "$lib" "$tmpdir/crasher"
+cat > "$tmpdir/crasher/run-me.sh" <<EOF
+#!/bin/sh
+DSYMUTIL="\${DSYMUTIL:-llvm-dsymutil}"
+dir="\$(dirname \$0)"
+\$DSYMUTIL -oso-prepend-path="\$dir" "\$dir/$(basename "$lib")"
+exit \$?
+EOF
+chmod +x "$tmpdir/crasher/run-me.sh"
+(cd "$tmpdir"/crasher; DSYMUTIL=/builds/worker/workspace/build/src/llvm-dsymutil/bin/llvm-dsymutil ./run-me.sh > /dev/null 2>&1)
+if [ $? -eq 139 ]; then
+ echo "Could reproduce with a reduced testcase. Creating an artifact." >&2
+ mkdir -p "$HOME/artifacts"
+ artifact=dsymutil-crasher.tar.xz
+ tar -Jcf "$HOME/artifacts/$artifact" -C "$tmpdir" crasher/
+ echo "Check the $artifact artifact." >&2
+else
+ echo "Could not reproduce with a reduced testcase. Sorry." >&2
+fi
+
+exit 139
diff --git a/build/macosx/local-mozconfig.common b/build/macosx/local-mozconfig.common
new file mode 100644
index 0000000000..8103d4a927
--- /dev/null
+++ b/build/macosx/local-mozconfig.common
@@ -0,0 +1,28 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+. "$topsrcdir/build/mozconfig.common"
+
+if [ -d "$MOZ_FETCHES_DIR/clang" ]; then
+ # mozilla-central based build
+ export DSYMUTIL=$MOZ_FETCHES_DIR/clang/bin/llvm-dsymutil
+ # Use an updated linker.
+ ldflags="-B$MOZ_FETCHES_DIR/cctools/bin"
+ export AR=$MOZ_FETCHES_DIR/cctools/bin/ar
+fi
+
+# Ensure the updated linker doesn't generate things our older build tools
+# don't understand.
+ldflags="$ldflags -Wl,-no_data_in_code_info"
+export LDFLAGS="$ldflags"
+
+# If not set use the system default clang
+if [ -z "$CC" ]; then
+ export CC=clang
+fi
+
+# If not set use the system default clang++
+if [ -z "$CXX" ]; then
+ export CXX=clang++
+fi
diff --git a/build/macosx/mozconfig.common b/build/macosx/mozconfig.common
new file mode 100644
index 0000000000..ad234d290f
--- /dev/null
+++ b/build/macosx/mozconfig.common
@@ -0,0 +1,15 @@
+if test `uname -s` = Linux; then
+ . $topsrcdir/build/macosx/cross-mozconfig.common
+else
+ . $topsrcdir/build/macosx/local-mozconfig.common
+fi
+
+if [ -z "$USE_ARTIFACT" ]; then
+ if [ -n "$TASKCLUSTER_PGO_PROFILE_USE" ]; then
+ export MOZ_LTO=cross
+ ac_add_options --enable-profile-use=cross
+ ac_add_options --with-pgo-jarlog=${MOZ_FETCHES_DIR}/en-US.log
+ ac_add_options --with-pgo-profile-path=${MOZ_FETCHES_DIR}/merged.profdata
+ fi
+fi
+
diff --git a/build/macosx/permissions/chown_revert.c b/build/macosx/permissions/chown_revert.c
new file mode 100644
index 0000000000..72dc1e64d5
--- /dev/null
+++ b/build/macosx/permissions/chown_revert.c
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+ if (argc != 2) return 1;
+
+ uid_t realuser = getuid();
+ char uidstring[20];
+ snprintf(uidstring, 19, "%i", realuser);
+ uidstring[19] = '\0';
+
+ return execl("/usr/sbin/chown", "/usr/sbin/chown", "-R", "-h", uidstring,
+ argv[1], (char*)0);
+}
diff --git a/build/macosx/permissions/chown_root.c b/build/macosx/permissions/chown_root.c
new file mode 100644
index 0000000000..e2ef111c7f
--- /dev/null
+++ b/build/macosx/permissions/chown_root.c
@@ -0,0 +1,12 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <unistd.h>
+
+int main(int argc, char** argv) {
+ if (argc != 2) return 1;
+
+ return execl("/usr/sbin/chown", "/usr/sbin/chown", "-R", "-h", "root:admin",
+ argv[1], (char*)0);
+}