From c6e0aad40b113c84758396e2c7e28acd461135ac Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sun, 1 Jan 2023 19:43:57 +0100 Subject: [PATCH] make: move extra builds to "build/extra/" subdirectories --- .github/workflows/ci.yml | 68 ++++++------- Makefile | 98 ++++++++++--------- .../20-image-run-shell.sh | 8 +- .../build-all-inside-container.sh | 2 +- .../20-image-run-shell.sh | 8 +- 5 files changed, 94 insertions(+), 90 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0f10ede..b9bad471 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,25 +78,25 @@ jobs: with: { submodules: true } - name: 'Check out test suite' run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' - - name: 'Build cmake debug-gcc' - run: 'make build/debug-gcc' - - name: 'Build cmake release-gcc' - run: 'make build/release-gcc' - - name: 'Build cmake debug-clang' - run: 'make build/debug-clang' - - name: 'Build cmake release-clang' - run: 'make build/release-clang' - - name: 'Build cmake debug-gcc-m32' + - name: 'Build cmake extra/gcc/debug' + run: 'make build/extra/gcc/debug' + - name: 'Build cmake extra/gcc/release' + run: 'make build/extra/gcc/release' + - name: 'Build cmake extra/clang/debug' + run: 'make build/extra/clang/debug' + - name: 'Build cmake extra/clang/release' + run: 'make build/extra/clang/release' + - name: 'Build cmake extra/gcc-m32/debug' if: ${{ matrix.use_m32 }} - run: 'make build/debug-gcc-m32' - - name: 'Build cmake release-gcc-m32' + run: 'make build/extra/gcc-m32/debug' + - name: 'Build cmake extra/gcc-m32/release' if: ${{ matrix.use_m32 }} - run: 'make build/release-gcc-m32' + run: 'make build/extra/gcc-m32/release' - name: 'Make artifact' run: | N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }} mkdir -p "tmp/artifact/$N" - (cd build && cp -ai --parents */upx "../tmp/artifact/$N") + (cd build/extra && cp -ai --parents */*/upx "../../tmp/artifact/$N") (cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV @@ -107,20 +107,20 @@ jobs: path: tmp/artifact - name: 'Run basic tests' run: | - make -C build/debug-gcc test - make -C build/release-gcc test - make -C build/debug-clang test - make -C build/release-clang test + make -C build/extra/gcc/debug test + make -C build/extra/gcc/release test + make -C build/extra/clang/debug test + make -C build/extra/clang/release test - name: 'Run basic tests 32-bit' if: ${{ matrix.use_m32 }} run: | - make -C build/debug-gcc-m32 test - make -C build/release-gcc-m32 test - - name: 'Run test suite build/release-gcc' + make -C build/extra/gcc-m32/debug test + make -C build/extra/gcc-m32/release test + - name: 'Run test suite build/extra/gcc/release' run: | export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" testsuite_1=$(readlink -en ./.github/travis_testsuite_1.sh) - env -C build/release-gcc upx_exe=./upx bash "$testsuite_1" + env -C build/extra/gcc/release upx_exe=./upx bash "$testsuite_1" job-macos-cmake: needs: [ job-rebuild-and-verify-stubs ] @@ -144,21 +144,21 @@ jobs: with: { submodules: true } - name: 'Check out test suite' run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' - - name: 'Build cmake debug-gcc' + - name: 'Build cmake extra/gcc/debug' if: ${{ matrix.gcc != '' }} - run: 'make build/debug-gcc CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}' - - name: 'Build cmake release-gcc' + run: 'make build/extra/gcc/debug CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}' + - name: 'Build cmake extra/gcc/release' if: ${{ matrix.gcc != '' }} - run: 'make build/release-gcc CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}' - - name: 'Build cmake debug-clang' - run: 'make build/debug-clang' - - name: 'Build cmake release-clang' - run: 'make build/release-clang' + run: 'make build/extra/gcc/release CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}' + - name: 'Build cmake extra/clang/debug' + run: 'make build/extra/clang/debug' + - name: 'Build cmake extra/clang/release' + run: 'make build/extra/clang/release' - name: 'Make artifact' run: | N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }} mkdir -p "tmp/artifact/$N" - (cd build && rsync -R -a */upx "../tmp/artifact/$N/") + (cd build/extra && rsync -R -a */*/upx "../../tmp/artifact/$N/") (cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV @@ -169,15 +169,15 @@ jobs: path: tmp/artifact - name: 'Run basic tests' run: | - make -C build/debug-clang test - make -C build/release-clang test - - name: 'Run test suite build/release-clang' + make -C build/extra/clang/debug test + make -C build/extra/clang/release test + - name: 'Run test suite build/extra/clang/release' if: ${{ matrix.testsuite }} run: | export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" testsuite_1=$(readlink -en ./.github/travis_testsuite_1.sh) - env -C build/release-clang upx_exe=./upx bash "$testsuite_1" + env -C build/extra/clang/release upx_exe=./upx bash "$testsuite_1" job-windows-cmake: needs: [ job-rebuild-and-verify-stubs ] diff --git a/Makefile b/Makefile index 023b4bc3..71635db4 100644 --- a/Makefile +++ b/Makefile @@ -18,9 +18,11 @@ endif # default #*********************************************************************** -__check_cache = $(if $(wildcard $1/CMakeCache.txt),@true,) -run_config = $(call __check_cache,$1) $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2 -run_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2 +run_cmake_config = $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2 +run_cmake_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2 +# avoid re-running run_cmake_config if CMakeCache.txt already exists +run_config = $(if $(wildcard $1/CMakeCache.txt),,$(call run_cmake_config,$1,$2)) +run_build = $(call run_cmake_build,$1,$2) .DEFAULT_GOAL = build/release @@ -39,7 +41,7 @@ release: build/release .PHONY: PHONY #*********************************************************************** -# extra convenience: some pre-defined build configurations +# extra builds: some pre-defined build configurations #*********************************************************************** define run_config_and_build @@ -48,68 +50,68 @@ define run_config_and_build endef # force building with clang/clang++ -build/debug-clang: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-clang: PHONY ; $(call run_config_and_build,$@,Release) -build/%-clang: export CC = clang -build/%-clang: export CXX = clang++ +build/extra/clang/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/clang/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/clang/%: export CC = clang +build/extra/clang/%: export CXX = clang++ # force building with clang/clang++ -m32 -build/debug-clang-m32: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-clang-m32: PHONY ; $(call run_config_and_build,$@,Release) -build/%-clang-m32: export CC = clang -m32 -build/%-clang-m32: export CXX = clang++ -m32 +build/extra/clang-m32/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/clang-m32/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/clang-m32/%: export CC = clang -m32 +build/extra/clang-m32/%: export CXX = clang++ -m32 # force building with clang/clang++ -m64 -build/debug-clang-m64: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-clang-m64: PHONY ; $(call run_config_and_build,$@,Release) -build/%-clang-m64: export CC = clang -m64 -build/%-clang-m64: export CXX = clang++ -m64 +build/extra/clang-m64/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/clang-m64/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/clang-m64/%: export CC = clang -m64 +build/extra/clang-m64/%: export CXX = clang++ -m64 # force building with gcc/g++ -build/debug-gcc: PHONY; $(call run_config_and_build,$@,Debug) -build/release-gcc: PHONY; $(call run_config_and_build,$@,Release) -build/%-gcc: export CC = gcc -build/%-gcc: export CXX = g++ +build/extra/gcc/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/gcc/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/gcc/%: export CC = gcc +build/extra/gcc/%: export CXX = g++ # force building with gcc/g++ -m32 -build/debug-gcc-m32: PHONY; $(call run_config_and_build,$@,Debug) -build/release-gcc-m32: PHONY; $(call run_config_and_build,$@,Release) -build/%-gcc-m32: export CC = gcc -m32 -build/%-gcc-m32: export CXX = g++ -m32 +build/extra/gcc-m32/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/gcc-m32/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/gcc-m32/%: export CC = gcc -m32 +build/extra/gcc-m32/%: export CXX = g++ -m32 # force building with gcc/g++ -m64 -build/debug-gcc-m64: PHONY; $(call run_config_and_build,$@,Debug) -build/release-gcc-m64: PHONY; $(call run_config_and_build,$@,Release) -build/%-gcc-m64: export CC = gcc -m64 -build/%-gcc-m64: export CXX = g++ -m64 +build/extra/gcc-m64/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/gcc-m64/%: export CC = gcc -m64 +build/extra/gcc-m64/%: export CXX = g++ -m64 # cross compiler: Linux glibc aarch64-linux-gnu -build/debug-cross-linux-aarch64: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-cross-linux-aarch64: PHONY ; $(call run_config_and_build,$@,Release) -build/%-cross-linux-aarch64: export CC = aarch64-linux-gnu-gcc -build/%-cross-linux-aarch64: export CXX = aarch64-linux-gnu-g++ +build/extra/cross-linux-aarch64/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/cross-linux-aarch64/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/cross-linux-aarch64/%: export CC = aarch64-linux-gnu-gcc +build/extra/cross-linux-aarch64/%: export CXX = aarch64-linux-gnu-g++ # cross compiler: Linux glibc arm-linux-gnueabihf -build/debug-cross-linux-arm: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-cross-linux-arm: PHONY ; $(call run_config_and_build,$@,Release) -build/%-cross-linux-arm: export CC = arm-linux-gnueabihf-gcc -build/%-cross-linux-arm: export CXX = arm-linux-gnueabihf-g++ -Wno-psabi +build/extra/cross-linux-arm/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/cross-linux-arm/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/cross-linux-arm/%: export CC = arm-linux-gnueabihf-gcc +build/extra/cross-linux-arm/%: export CXX = arm-linux-gnueabihf-g++ -Wno-psabi # cross compiler: Windows win32 mingw32 -build/debug-cross-mingw32: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-cross-mingw32: PHONY ; $(call run_config_and_build,$@,Release) -build/%-cross-mingw32: export CC = i686-w64-mingw32-gcc -build/%-cross-mingw32: export CXX = i686-w64-mingw32-g++ -# disable sanitize to avoid link errors on GitHub CI -build/%-cross-mingw32: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1 +build/extra/cross-mingw32/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/cross-mingw32/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/cross-mingw32/%: export CC = i686-w64-mingw32-gcc +build/extra/cross-mingw32/%: export CXX = i686-w64-mingw32-g++ +# disable sanitize to avoid link errors with current MinGW-w64 versions +build/extra/cross-mingw32/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1 # cross compiler: Windows win64 mingw64 -build/debug-cross-mingw64: PHONY ; $(call run_config_and_build,$@,Debug) -build/release-cross-mingw64: PHONY ; $(call run_config_and_build,$@,Release) -build/%-cross-mingw64: export CC = x86_64-w64-mingw32-gcc -build/%-cross-mingw64: export CXX = x86_64-w64-mingw32-g++ -# disable sanitize to avoid link errors on GitHub CI -build/%-cross-mingw64: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1 +build/extra/cross-mingw64/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/cross-mingw64/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/cross-mingw64/%: export CC = x86_64-w64-mingw32-gcc +build/extra/cross-mingw64/%: export CXX = x86_64-w64-mingw32-g++ +# disable sanitize to avoid link errors with current MinGW-w64 versions +build/extra/cross-mingw64/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1 #*********************************************************************** # check git submodules diff --git a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh index 7c9e7e22..42b0b47a 100755 --- a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh +++ b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh @@ -34,7 +34,9 @@ podman run "${flags[@]}" "$image" bash -l # now we can cross-compile UPX for Windows: # cd /home/upx/src/upx -# rm -rf ./build/release-cross-mingw64 -# make build/release-cross-mingw64 +# rm -rf ./build/extra/cross-mingw64/release +# make build/extra/cross-mingw64/release -# lots of other cross-compilers are installed; see "ls /usr/bin/*g++*" +# lots of other cross-compilers are installed: +# - see "ls /usr/bin/*g++*" +# - see misc/cross-compile-upx-with-podman/build-all-inside-container.sh diff --git a/misc/cross-compile-upx-with-podman/build-all-inside-container.sh b/misc/cross-compile-upx-with-podman/build-all-inside-container.sh index e485c398..5237694d 100755 --- a/misc/cross-compile-upx-with-podman/build-all-inside-container.sh +++ b/misc/cross-compile-upx-with-podman/build-all-inside-container.sh @@ -27,7 +27,7 @@ function run_config_and_build { # these old architectures do not support sanitize alpha-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; hppa-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; - # avoid link errors with Windows cross compilers; need to install some more support libs?? + # avoid link errors with current MinGW-w64 versions i686-w64-mingw32) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; x86_64-w64-mingw32) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; # avoid warnings about arm libstdc++ ABI change in gcc-7 diff --git a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh index 5c5962f9..12e8dd1d 100755 --- a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh +++ b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh @@ -47,11 +47,11 @@ podman run "${flags[@]}" "$image" bash -l # we can also build UPX in the container: # cd /home/upx/src/upx -# rm -rf ./build/release -# make build/release +# rm -rf ./build/extra/gcc/release +# make build/extra/gcc/release # # run tests -# ./build/release/upx --version -# make -C build/release test +# ./build/extra/gcc/release/upx --version +# make -C build/extra/gcc/release test # and we can also rebuild the UPX docs the container: # cd /home/upx/src/upx