Commit 8fbb192b authored by brizental's avatar brizental
Browse files

Bug 41393 - Create special clang packaged for Linux

Building Firefox requires compiler-rt wasm32 library to be
packaged alongside clang.

We were doing this step inside the firefox and geckoview
projects, but that meant one can't simply download the clang
toolchain and use it for dev builds.

MacOS and Windows already have separate projects to package
clang with other libraries, so a step to include the wasm32
compiler-rt lib was added to each of them.
parent 65743657
Loading
Loading
Loading
Loading
+3 −0
Changes for projects/clang-linux/README.md: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
This projects packages extra libraries and tools alongside clang for Firefox developement
on Linux and Android. It is the default compiler for 'firefox' and 'geckoview' projects
on Linux and Android.
+21 −0
Changes for projects/clang-linux/build: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
[% c("var/set_default_env") -%]
distdir=/var/tmp/dist/[% project %]
mkdir -p /var/tmp/dist

tar -C /var/tmp/dist -xf [% c('input_files_by_name/clang') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/wasi-compiler-rt') %]

[% IF c("var/android") -%]
  tar -C /var/tmp/dist -xf [% c('input_files_by_name/llvm-runtimes') %]
  cp -r /var/tmp/dist/llvm-runtimes/* /var/tmp/dist/clang
[% END -%]

mkdir $distdir
mv /var/tmp/dist/clang/* $distdir/

cd /var/tmp/dist
[% c('tar', {
    tar_src => [ project ],
    tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
  }) %]
+16 −0
Changes for projects/clang-linux/config: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
# vim: filetype=yaml sw=2
version: '[% c("var/llvm_version") %]'
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]'
container:
  use_container: 1

input_files:
  - project: container-image
  - name: clang
    project: clang
  - project: wasi-sysroot
    name: wasi-compiler-rt
    pkg_type: build_compiler_rt
  - project: llvm-runtimes
    name: llvm-runtimes
    enable: '[% c("var/android") %]'
+4 −2
Changes for projects/clang/README.md: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
This is the Clang compiler.

For Linux and Android, we use it only to build Firefox and GeckoView.
For Windows and macOS, we use it to build everything, but we do not use this
For Linux and Android, we use it only to build Firefox and GeckoView, but we do
not use this project directly. Instead, we use `clang-linux`,
that adds platform-specific libraries and tools.
For Windows and macOS, we use it to build everything, but we also do not use this
project directly. Instead, we use `mingw-w64-clang` and `macosx_toolchain`, that
also add platform-specific libraries and tools.

+2 −15
Changes for projects/firefox/build: 2 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ export PATH="/var/tmp/dist/rust/bin:/var/tmp/dist/cbindgen:/var/tmp/dist/node/bi
  [% END -%]
  # Use clang for everything on Linux now if we don't build with ASan.
  [% IF ! c("var/asan") -%]
    export PATH="/var/tmp/dist/clang/bin:$PATH"
    export PATH="/var/tmp/dist/clang-linux/bin:$PATH"
  [% END -%]
  [% IF c("var/linux-i686") -%]
    # Exporting `PKG_CONFIG_PATH` in the mozconfig file is causing build
@@ -51,20 +51,7 @@ export PATH="/var/tmp/dist/rust/bin:/var/tmp/dist/cbindgen:/var/tmp/dist/node/bi

[% IF c("var/rlbox") -%]
  tar -C /var/tmp/dist -xf [% c('input_files_by_name/wasi-sysroot') %]
  # XXX: We need the libclang_rt.builtins-wasm32.a in our clang lib directory.
  # Copy it over.
  # https://searchfox.org/mozilla-central/source/build/build-clang/build-clang.py#890,
  # include it directly in our clang
  [% IF c("var/macos") -%]
    rtdir=/var/tmp/dist/macosx-toolchain/clang/lib/clang/[% pc("llvm-project", "var/llvm_major") %]/lib/wasi
  [% ELSIF c("var/windows") -%]
    rtdir=/var/tmp/dist/mingw-w64-clang/lib/clang/[% pc("llvm-project", "var/llvm_major") %]/lib/wasi
  [% ELSE -%]
    rtdir=/var/tmp/dist/clang/lib/clang/[% pc("llvm-project", "var/llvm_major") %]/lib/wasi
  [% END -%]
  mkdir -p $rtdir
  cp /var/tmp/dist/wasi-sysroot/lib/clang/*/lib/wasi/libclang_rt.builtins-wasm32.a $rtdir
  export WASI_SYSROOT=/var/tmp/dist/wasi-sysroot/share/wasi-sysroot
  export WASI_SYSROOT=/var/tmp/dist/wasi-sysroot
[% END -%]

tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.[% c('compress_tar') %]
Loading