Skip to main content
Sign in
Snippets Groups Projects
Verified Commit 3c17b385 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

Bug 40606: Use Clang to compile NSIS

NSIS officially supports only MSVC and GCC as compilers, so it was one
of the two projects forcing us to keep a GCC toolchain for Windows.
With this commit, we adapt the tricks Mozilla uses to build NSIS with
Clang, and remove the dependency on mingw-w64.

The main trick is to use the GNU assembler instead of Clang's internal
one to build NSIS's system plugin. Luckily, it can be found in
binutils, without a full GCC build.
parent 4ea089e4
Branches
Tags
1 merge request!890Bug 40606&40900: Use Clang to compile NSIS and update it to 3.09
......@@ -4,10 +4,38 @@
mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf nsis-[% c('version') %].tar.bz2
# We need the GNU assembler for the system plugin
tar -C /var/tmp/dist -xf [% c('input_files_by_name/binutils') %]
# NSIS requires zlib and we later set the path using ZLIB_W32.
tar -C /var/tmp/build -xf [% c('input_files_by_name/zlib') %]
# This trick is adapted from Firefox's
# taskcluster/scripts/misc/build-mingw32-nsis.sh
compiler_prefix=/var/tmp/dist/mingw-w64-clang/bin/[% c("arch") %]-w64-mingw32
cat <<'EOF' >"$compiler_prefix-gcc"
#!/bin/sh
# SCons ignores the external $PATH, so we add binutils here.
export PATH=/var/tmp/dist/binutils/bin:$PATH
case "$@" in
*/Call*.S)
$(dirname $0)/[% c("arch") %]-w64-mingw32-clang -fno-integrated-as "$@"
;;
*)
$(dirname $0)/[% c("arch") %]-w64-mingw32-clang "$@"
;;
esac
EOF
chmod +x "$compiler_prefix-gcc"
ln -s "$compiler_prefix-clang++" "$compiler_prefix-g++"
cd /var/tmp/build/nsis-[% c('version') %]-src
# These two sed commands also come from build-mingw32-nsis.sh
sed -i 's/-Wl,--exclude-libs,msvcrt.a/-Wl,-Xlink=-fixed/' SCons/Config/gnu
sed -i '2i extern "C"' SCons/Config/{memcpy,memset}.c
# Adding --no-insert-timestamp to APPEND_LINKFLAGS is not working as it
# is used for both the host and cross-compiled parts, but this option is
# only valid for the Windows linker. Therefore we add it using a patch
......@@ -30,8 +58,7 @@ patch -p1 < $rootdir/no-reloc-section.diff
[% END %]
[% SET scons_args = 'VERSION=' _ c("version")
_ ' APPEND_CCFLAGS="-fgnu89-inline"'
_ " SKIPUTILS='NSIS Menu' XGCC_W32_PREFIX=" _ c("arch") _ "-w64-mingw32-"
_ " SKIPUTILS='NSIS Menu,Makensisw' XGCC_W32_PREFIX=" _ c("arch") _ "-w64-mingw32-"
_ " TARGET_ARCH=" _ target
_ " ZLIB_W32=/var/tmp/build/zlib/"
_ ' PREFIX=/var/tmp/dist/nsis' -%]
......
......
......@@ -11,12 +11,6 @@ var:
- zlib1g-dev
- libcppunit-dev
- xsltproc
# NSIS has an assembly part that cannot be compiled with Clang.
# Mozilla uses -fno-integrated-as (see
# taskcluster/scripts/misc/build-mingw32-nsis.sh) but for some reason this
# does not seem to work for us, so just keep GCC for the moment, since we are
# already using it for Rust anyway.
compiler: mingw-w64
input_files:
- project: container-image
......@@ -27,5 +21,7 @@ input_files:
- filename: no-reloc-section.diff
- name: '[% c("var/compiler") %]'
project: '[% c("var/compiler") %]'
- name: binutils
project: binutils
- name: zlib
project: zlib
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment