Skip to content

Commit 1a038d5

Browse files
authored
Merge pull request #5 from NixOS/master
Merge pull request NixOS#441 from NixOS/ci
2 parents 268c926 + ad02656 commit 1a038d5

25 files changed

+2512
-280
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10-
- uses: cachix/install-nix-action@v17
10+
- uses: cachix/install-nix-action@v18
1111
- run: nix-build -A hydraJobs.release
1212
ubuntu:
1313
runs-on: ubuntu-latest

.github/workflows/publish.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,60 @@ jobs:
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v3
17-
- uses: cachix/install-nix-action@v17
17+
- uses: cachix/install-nix-action@v18
1818
- name: Build tarballs
1919
run: |
20-
nix-build -A hydraJobs.tarball
20+
nix build -L .#hydraJobs.tarball
2121
install -D ./result/tarballs/*.tar.bz2 ./dist/patchelf-$(cat version).tar.bz2
2222
install -D ./result/tarballs/*.tar.gz ./dist/patchelf-$(cat version).tar.gz
2323
- uses: actions/upload-artifact@v3
2424
with:
2525
name: patchelf
2626
path: dist/*
2727

28-
build_binaries:
28+
build_windows:
29+
name: Build windows executable
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
- uses: cachix/install-nix-action@v18
35+
- name: Build windows executable
36+
run: |
37+
nix build -L .#patchelf-win32 .#patchelf-win64
38+
install -D ./result/bin/patchelf.exe ./dist/patchelf-win32.exe
39+
install -D ./result-1/bin/patchelf.exe ./dist/patchelf-win64.exe
40+
- uses: actions/upload-artifact@v3
41+
with:
42+
name: patchelf
43+
path: dist/*
44+
45+
test_windows:
46+
name: Test windows binaries
47+
needs: [build_windows]
48+
runs-on: windows-latest
49+
steps:
50+
- uses: actions/checkout@v2
51+
- uses: actions/download-artifact@v3
52+
with:
53+
name: patchelf
54+
path: dist
55+
- name: Show binaries
56+
run: dir .\\dist
57+
- name: Test windows 64-bit binary
58+
run: .\\dist\\patchelf-win32.exe --version
59+
60+
- name: Test windows 32-bit binary
61+
run: .\\dist\\patchelf-win64.exe --version
62+
63+
build_musl:
2964
name: Build static musl binaries
3065
needs: [build_tarballs]
3166
runs-on: ubuntu-latest
3267
strategy:
3368
fail-fast: false
3469
matrix:
35-
platform: ["amd64", "i386", "ppc64le", "arm64v8", "arm32v7", "s390x"]
70+
platform: ["amd64", "i386", "ppc64le", "arm64v8", "arm32v7", "s390x", "riscv64"]
3671
steps:
3772
- name: Set up QEMU
3873
if: matrix.platform != 'amd64'
@@ -65,7 +100,7 @@ jobs:
65100
else
66101
ENTRYPOINT=
67102
fi
68-
docker run -e CXXFLAGS -v $(pwd):/gha ${{ matrix.platform }}/alpine:3.16 ${ENTRYPOINT} sh -ec "cd /gha && sh ./build.sh"
103+
docker run -e CXXFLAGS -v $(pwd):/gha ${{ matrix.platform }}/alpine:edge ${ENTRYPOINT} sh -ec "cd /gha && sh ./build.sh"
69104
- name: Check binaries
70105
run: |
71106
cat <<EOF > check.sh
@@ -74,15 +109,15 @@ jobs:
74109
tar -xf ./dist/patchelf-*-*.tar.gz
75110
./bin/patchelf --version
76111
EOF
77-
docker run -v $(pwd):/gha ${{ matrix.platform }}/debian:stable-slim sh -ec "cd /gha && sh ./check.sh"
112+
docker run -v $(pwd):/gha ${{ matrix.platform }}/debian:unstable-slim sh -ec "cd /gha && sh ./check.sh"
78113
- uses: actions/upload-artifact@v3
79114
with:
80115
name: patchelf
81116
path: dist/*
82117

83118
publish:
84119
name: Publish tarballs & binaries
85-
needs: [build_tarballs, build_binaries]
120+
needs: [build_tarballs, build_windows, build_musl]
86121
if: github.event_name == 'push' && github.repository == 'NixOS/patchelf' && startsWith(github.ref, 'refs/tags/')
87122
runs-on: ubuntu-latest
88123
steps:

configure.ac

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror dist-bzip2 foreign color-tests parallel-t
66
AC_CONFIG_MACRO_DIR([m4])
77

88
AC_CHECK_TOOL([STRIP], [strip])
9+
# Those are only used in tests, hence we gracefully degrate if they are not found.
10+
AC_CHECK_TOOL([OBJDUMP], [objdump], [objdump])
11+
AC_CHECK_TOOL([OBJCOPY], [objcopy], [objcopy])
12+
AC_CHECK_TOOL([READELF], [readelf], [readelf])
913

1014
AM_PROG_CC_C_O
1115
AC_PROG_CXX
@@ -28,17 +32,12 @@ AC_ARG_WITH([asan],
2832
)
2933
AM_CONDITIONAL([WITH_ASAN], [test x"$with_asan" = xyes])
3034

35+
AX_CXX_COMPILE_STDCXX([17], [noext], [])
36+
3137
AC_ARG_WITH([ubsan],
3238
AS_HELP_STRING([--with-ubsan], [Build with undefined behavior sanitizer])
3339
)
3440
AM_CONDITIONAL([WITH_UBSAN], [test x"$with_ubsan" = xyes])
3541

36-
CPLUSPLUS=
37-
AX_CHECK_COMPILE_FLAG([-std=c++17], [CPLUSPLUS=17], [], [$WERROR])
38-
39-
if test -z "$CPLUSPLUS"; then
40-
AC_MSG_ERROR([Your compiler does not have the necessary C++17 support! Cannot proceed.])
41-
fi
42-
4342
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile patchelf.spec])
4443
AC_OUTPUT

flake.lock

Lines changed: 22 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 58 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
{
22
description = "A tool for modifying ELF executables and libraries";
33

4-
inputs.nixpkgs.url = "nixpkgs/nixos-21.05";
4+
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
5+
inputs.nixpkgs-mingw.url = "github:Mic92/nixpkgs/mingw";
56

6-
outputs = { self, nixpkgs }:
7+
outputs = { self, nixpkgs, nixpkgs-mingw }:
78

89
let
910
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
10-
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
11-
12-
nixpkgsFor = forAllSystems (system:
13-
import nixpkgs {
14-
inherit system;
15-
overlays = [ self.overlay ];
16-
}
17-
);
18-
version = builtins.readFile ./version;
19-
pkgs = nixpkgsFor.${"x86_64-linux"};
11+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
12+
13+
version = nixpkgs.lib.removeSuffix "\n" (builtins.readFile ./version);
14+
pkgs = nixpkgs.legacyPackages.x86_64-linux;
15+
16+
patchelfFor = pkgs: pkgs.callPackage ./patchelf.nix {
17+
inherit version;
18+
src = self;
19+
};
20+
21+
# https://github.com/NixOS/nixpkgs/pull/199883
22+
pkgsCrossForMingw = system: (import nixpkgs-mingw {
23+
inherit system;
24+
overlays = [
25+
(final: prev: {
26+
threadsCross = {
27+
model = "win32";
28+
package = null;
29+
};
30+
})
31+
];
32+
}).pkgsCross;
33+
2034
in
2135

2236
{
23-
overlay = final: prev: {
24-
patchelf-new-musl = final.pkgsMusl.callPackage ./patchelf.nix {
25-
inherit version;
26-
src = self;
27-
};
28-
patchelf-new = final.callPackage ./patchelf.nix {
29-
inherit version;
30-
src = self;
31-
};
37+
overlays.default = final: prev: {
38+
patchelf-new-musl = patchelfFor final.pkgsMusl;
39+
patchelf-new = patchelfFor final;
3240
};
3341

3442
hydraJobs = {
@@ -57,8 +65,8 @@
5765
'';
5866
});
5967

60-
build = forAllSystems (system: nixpkgsFor.${system}.patchelf-new);
61-
build-sanitized = forAllSystems (system: nixpkgsFor.${system}.patchelf-new.overrideAttrs (old: {
68+
build = forAllSystems (system: self.packages.${system}.patchelf);
69+
build-sanitized = forAllSystems (system: self.packages.${system}.patchelf.overrideAttrs (old: {
6270
configureFlags = [ "--with-asan " "--with-ubsan" ];
6371
# -Wno-unused-command-line-argument is for clang, which does not like
6472
# our cc wrapper arguments
@@ -67,16 +75,22 @@
6775

6876
# x86_64-linux seems to be only working clangStdenv at the moment
6977
build-sanitized-clang = nixpkgs.lib.genAttrs [ "x86_64-linux" ] (system: self.hydraJobs.build-sanitized.${system}.override {
70-
stdenv = nixpkgsFor.${system}.llvmPackages_latest.libcxxStdenv;
78+
stdenv = nixpkgs.legacyPackages.${system}.llvmPackages_latest.libcxxStdenv;
7179
});
7280

81+
# To get mingw compiler from hydra cache
82+
inherit (self.packages.x86_64-linux) patchelf-win32 patchelf-win64;
83+
7384
release = pkgs.releaseTools.aggregate
7485
{ name = "patchelf-${self.hydraJobs.tarball.version}";
7586
constituents =
7687
[ self.hydraJobs.tarball
7788
self.hydraJobs.build.x86_64-linux
7889
self.hydraJobs.build.i686-linux
90+
# FIXME: add aarch64 emulation to our github action...
91+
#self.hydraJobs.build.aarch64-linux
7992
self.hydraJobs.build-sanitized.x86_64-linux
93+
#self.hydraJobs.build-sanitized.aarch64-linux
8094
self.hydraJobs.build-sanitized.i686-linux
8195
self.hydraJobs.build-sanitized-clang.x86_64-linux
8296
];
@@ -89,23 +103,30 @@
89103
build = self.hydraJobs.build.${system};
90104
});
91105

92-
devShell = forAllSystems (system: self.devShells.${system}.glibc);
106+
devShells = forAllSystems (system: {
107+
glibc = self.packages.${system}.patchelf;
108+
default = self.devShells.${system}.glibc;
109+
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
110+
musl = self.packages.${system}.patchelf-musl;
111+
});
93112

94-
devShells = forAllSystems (system:
95-
{
96-
glibc = self.packages.${system}.patchelf;
97-
musl = self.packages.${system}.patchelf-musl;
98-
});
113+
packages = forAllSystems (system: {
114+
patchelf = patchelfFor nixpkgs.legacyPackages.${system};
115+
default = self.packages.${system}.patchelf;
99116

100-
defaultPackage = forAllSystems (system:
101-
self.packages.${system}.patchelf
102-
);
117+
# This is a good test to see if packages can be cross-compiled. It also
118+
# tests if our testsuite uses target-prefixed executable names.
119+
patchelf-musl-cross = patchelfFor nixpkgs.legacyPackages.${system}.pkgsCross.musl64;
103120

104-
packages = forAllSystems (system:
105-
{
106-
patchelf = nixpkgsFor.${system}.patchelf-new;
107-
patchelf-musl = nixpkgsFor.${system}.patchelf-new-musl;
121+
patchelf-win32 = (patchelfFor (pkgsCrossForMingw system).mingw32).overrideAttrs (old: {
122+
NIX_CFLAGS_COMPILE = "-static";
108123
});
124+
patchelf-win64 = (patchelfFor (pkgsCrossForMingw system).mingwW64).overrideAttrs (old: {
125+
NIX_CFLAGS_COMPILE = "-static";
126+
});
127+
} // nixpkgs.lib.optionalAttrs (system != "i686-linux") {
128+
patchelf-musl = patchelfFor nixpkgs.legacyPackages.${system}.pkgsMusl;
129+
});
109130

110131
};
111132
}

m4/ax_check_compile_flag.m4

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)