From 9f6df25a5256f4897b7e2c53929c182e47afa0ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 6 Apr 2021 15:16:23 +0200
Subject: [PATCH] CI: streamline compilation commands
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

— add “-s” to LDFLAGS instead of manually calling strip
— on GNU/Linux, do not pass “-static” to LDFLAGS. We can dynamically link
  against glibc, since in Artifacts.toml we explicitly mention that we compile
  for a glibc system (and not musl)
— use --host=i686-linux-gnu to compile for GNU/Linux 32-bit, instead of passing “-m32”
  N.B.: Under Debian, g++-i686-linux-gnu must be installed. Otherwise this will
  silently use the 64-bit compiler
— for symmetry, use --host=x86_64-linux-gnu for GNU/Linux 64-bit
— on macOS, pass “-static-libgcc” through LDFLAGS rather than CXXFLAGS; this
  requires setting CC to gcc-10
— use better names for the jobs
---
 .gitlab-ci.yml | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 01d1b231..dd7bcde3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,33 +9,31 @@ stages:
   - build
   - deploy
 
-build_linux_32:
+build_linux_i686:
   stage: build
   script:
     - autoreconf -si
-    - './configure LDFLAGS="-m32 -static -static-libgcc -static-libstdc++" CXXFLAGS=-m32'
+    - './configure --host=i686-linux-gnu LDFLAGS="-static-libstdc++ -static-libgcc -s"'
     - make -j$(nproc)
-    - strip src/dynare-preprocessor
     - mkdir -p $CI_COMMIT_SHA/linux-i686
     - tar -caf $CI_COMMIT_SHA/linux-i686/dynare-preprocessor.tar.gz -C src dynare-preprocessor
   artifacts:
     paths:
       - $CI_COMMIT_SHA/linux-i686/*
 
-build_linux_64:
+build_linux_x86_64:
   stage: build
   script:
     - autoreconf -si
-    - './configure LDFLAGS="-static -static-libgcc -static-libstdc++"'
+    - './configure --host=x86_64-linux-gnu LDFLAGS="-static-libstdc++ -static-libgcc -s"'
     - make -j$(nproc)
-    - strip src/dynare-preprocessor
     - mkdir -p $CI_COMMIT_SHA/linux-x86_64
     - tar -caf $CI_COMMIT_SHA/linux-x86_64/dynare-preprocessor.tar.gz -C src dynare-preprocessor
   artifacts:
     paths:
       - $CI_COMMIT_SHA/linux-x86_64/*
 
-build_windows_32:
+build_windows_i686:
   stage: build
   script:
     - mkdir -p ~/tarballs
@@ -43,16 +41,15 @@ build_windows_32:
     - mkdir -p deps
     - tar xf ~/tarballs/mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.zst --directory deps
     - autoreconf -si
-    - './configure --host=i686-w64-mingw32 --with-boost=$(pwd)/deps/mingw32/include LDFLAGS="-static -static-libgcc -static-libstdc++"'
+    - './configure --host=i686-w64-mingw32 --with-boost=$(pwd)/deps/mingw32/include LDFLAGS="-static -static-libgcc -static-libstdc++ -s"'
     - make -j$(nproc)
-    - i686-w64-mingw32-strip src/dynare-preprocessor.exe
     - mkdir -p $CI_COMMIT_SHA/windows-i686
     - tar -caf $CI_COMMIT_SHA/windows-i686/dynare-preprocessor.tar.gz -C src dynare-preprocessor.exe
   artifacts:
     paths:
       - $CI_COMMIT_SHA/windows-i686/*
 
-build_windows_64:
+build_windows_x86_64:
   stage: build
   script:
     - mkdir -p ~/tarballs
@@ -60,24 +57,22 @@ build_windows_64:
     - mkdir -p deps
     - tar xf ~/tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst --directory deps
     - autoreconf -si
-    - './configure --host=x86_64-w64-mingw32 --with-boost=$(pwd)/deps/mingw64/include LDFLAGS="-static -static-libgcc -static-libstdc++"'
+    - './configure --host=x86_64-w64-mingw32 --with-boost=$(pwd)/deps/mingw64/include LDFLAGS="-static -static-libgcc -static-libstdc++ -s"'
     - make -j$(nproc)
-    - x86_64-w64-mingw32-strip src/dynare-preprocessor.exe
     - mkdir -p $CI_COMMIT_SHA/windows-x86_64
     - tar -caf $CI_COMMIT_SHA/windows-x86_64/dynare-preprocessor.tar.gz -C src dynare-preprocessor.exe
   artifacts:
     paths:
       - $CI_COMMIT_SHA/windows-x86_64/*
 
-build_macOS:
+build_macos_x86_64:
   stage: build
   tags:
     - macOS
   script:
     - autoreconf -si
-    - './configure CXX=g++-10 CXXFLAGS=-static-libgcc LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison'
+    - './configure CC=gcc-10 CXX=g++-10 LDFLAGS="-static-libgcc -s" LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison'
     - make -j$(nproc)
-    - strip src/dynare-preprocessor
     - mkdir -p $CI_COMMIT_SHA/macos-x86_64
     - tar -caf $CI_COMMIT_SHA/macos-x86_64/dynare-preprocessor.tar.gz -C src dynare-preprocessor
   artifacts:
-- 
GitLab