Fix stripping and test it
This commit is contained in:
parent
2bfd2f169a
commit
d1d76ade32
65
.github/workflows/test.yml
vendored
65
.github/workflows/test.yml
vendored
@ -14,141 +14,161 @@ jobs:
|
|||||||
- platform_name: FreeBSD-x86_64
|
- platform_name: FreeBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-freebsd
|
target: x86_64-unknown-freebsd
|
||||||
expect_file: "x86-64.+FreeBSD"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "x86-64.+FreeBSD"
|
||||||
|
expect_stripped: false
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Linux-x86_64
|
- platform_name: Linux-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
expect_file: "ELF.+x86-64"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "ELF.+x86-64"
|
||||||
|
expect_stripped: true
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-aarch64
|
- platform_name: Linux-aarch64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: aarch64-unknown-linux-musl
|
target: aarch64-unknown-linux-musl
|
||||||
expect_file: "aarch64"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "aarch64"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-arm
|
- platform_name: Linux-arm
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: arm-unknown-linux-musleabi
|
target: arm-unknown-linux-musleabi
|
||||||
expect_file: "32.+ARM"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "32.+ARM"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-i586
|
- platform_name: Linux-i586
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: i586-unknown-linux-musl
|
target: i586-unknown-linux-musl
|
||||||
expect_file: "ELF.+80386"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "ELF.+80386"
|
||||||
|
expect_stripped: true
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips
|
- platform_name: Linux-mips
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips-unknown-linux-musl
|
target: mips-unknown-linux-musl
|
||||||
expect_file: "MIPS32.+mips-"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "MIPS32.+mips-"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mipsel
|
- platform_name: Linux-mipsel
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mipsel-unknown-linux-musl
|
target: mipsel-unknown-linux-musl
|
||||||
expect_file: "MIPS32.+mipsel-"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "MIPS32.+mipsel-"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64
|
- platform_name: Linux-mips64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64-unknown-linux-muslabi64
|
target: mips64-unknown-linux-muslabi64
|
||||||
expect_file: "MIPS64"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "MIPS64"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-mips64el
|
- platform_name: Linux-mips64el
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: mips64el-unknown-linux-muslabi64
|
target: mips64el-unknown-linux-muslabi64
|
||||||
expect_file: "MIPS64"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "MIPS64"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc
|
- platform_name: Linux-powerpc
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc-unknown-linux-gnu
|
target: powerpc-unknown-linux-gnu
|
||||||
expect_file: "32.+PowerPC"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "32.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64
|
- platform_name: Linux-powerpc64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64-unknown-linux-gnu
|
target: powerpc64-unknown-linux-gnu
|
||||||
expect_file: "64.+PowerPC"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "64.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-powerpc64le
|
- platform_name: Linux-powerpc64le
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: powerpc64le-unknown-linux-gnu
|
target: powerpc64le-unknown-linux-gnu
|
||||||
expect_file: "64.+PowerPC"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "64.+PowerPC"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-riscv64
|
- platform_name: Linux-riscv64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: riscv64gc-unknown-linux-gnu
|
target: riscv64gc-unknown-linux-gnu
|
||||||
expect_file: "64.+RISC-V"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "64.+RISC-V"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Linux-s390x
|
- platform_name: Linux-s390x
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: s390x-unknown-linux-gnu
|
target: s390x-unknown-linux-gnu
|
||||||
expect_file: "64.+S/390"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "64.+S/390"
|
||||||
|
expect_stripped: false
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: NetBSD-x86_64
|
- platform_name: NetBSD-x86_64
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
target: x86_64-unknown-netbsd
|
target: x86_64-unknown-netbsd
|
||||||
expect_file: "x86-64.+NetBSD"
|
|
||||||
expect_cross: true
|
expect_cross: true
|
||||||
|
expect_file: "x86-64.+NetBSD"
|
||||||
|
expect_stripped: false
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-aarch64
|
- platform_name: Windows-aarch64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: aarch64-pc-windows-msvc
|
target: aarch64-pc-windows-msvc
|
||||||
expect_file: "Aarch64.+Windows"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "Aarch64.+Windows"
|
||||||
|
expect_stripped: false
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
- platform_name: Windows-i686
|
- platform_name: Windows-i686
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: i686-pc-windows-msvc
|
target: i686-pc-windows-msvc
|
||||||
expect_file: "80386.+Windows"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "80386.+Windows"
|
||||||
|
expect_stripped: true
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: Windows-x86_64
|
- platform_name: Windows-x86_64
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
expect_file: "x86-64.+Windows"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "x86-64.+Windows"
|
||||||
|
expect_stripped: true
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-x86_64
|
- platform_name: macOS-x86_64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
expect_file: "Mach-O.+x86_64"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "Mach-O.+x86_64"
|
||||||
|
expect_stripped: true
|
||||||
can_test: true
|
can_test: true
|
||||||
|
|
||||||
- platform_name: macOS-aarch64
|
- platform_name: macOS-aarch64
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
expect_file: "Mach-O.+arm64"
|
|
||||||
expect_cross: false
|
expect_cross: false
|
||||||
|
expect_file: "Mach-O.+arm64"
|
||||||
|
expect_stripped: true
|
||||||
can_test: false
|
can_test: false
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform.os }}
|
runs-on: ${{ matrix.platform.os }}
|
||||||
@ -186,10 +206,11 @@ jobs:
|
|||||||
command: build
|
command: build
|
||||||
target: ${{ matrix.platform.target }}
|
target: ${{ matrix.platform.target }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Check for cross on ${{ matrix.platform.platform_name }}
|
strip: true
|
||||||
|
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
tests/check-binary.sh "${{ matrix.platform.target }}" "${{ matrix.platform.expect_cross }}" "${{ matrix.platform.expect_file }}"
|
tests/check-binary.sh "${{ matrix.platform.target }}" "${{ matrix.platform.expect_cross }}" "${{ matrix.platform.expect_file }}" "${{ matrix.platform.expect_stripped }}"
|
||||||
- name: Check that $PATH is not overwritten
|
- name: Check that $PATH is not overwritten
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -87,7 +87,6 @@ runs:
|
|||||||
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||||
- name: Strip binary
|
- name: Strip binary
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: strip-binary.sh ${{ inputs.target }}
|
||||||
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
|
|
||||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||||
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
|
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
|
||||||
|
|||||||
33
strip-binary.sh
Executable file
33
strip-binary.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
DIR=""
|
||||||
|
for type in debug release; do
|
||||||
|
if [ -d "target/$TARGET/$type" ]; then
|
||||||
|
DIR="target/$TARGET/$type"
|
||||||
|
break
|
||||||
|
elif [ -d "target/$type" ]; then
|
||||||
|
DIR="target/$type"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$DIR" ]; then
|
||||||
|
echo "Could not find directory with binary in it under target/"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||||
|
EXE=$( find "$DIR" -maxdepth 1 -type f -perm +111 )
|
||||||
|
else
|
||||||
|
EXE=$( find "$DIR" -maxdepth 1 -type f -executable )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$EXE" ]; then
|
||||||
|
echo "Could not find a binary to strip in $DIR"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
strip "$EXE"
|
||||||
@ -4,6 +4,7 @@ set -x
|
|||||||
TARGET=$1
|
TARGET=$1
|
||||||
EXPECT_CROSS=$2
|
EXPECT_CROSS=$2
|
||||||
EXPECT_FILE_RE=$3
|
EXPECT_FILE_RE=$3
|
||||||
|
EXPECT_STRIPPED=$4
|
||||||
|
|
||||||
if [ "$EXPECT_CROSS" == "true" ]; then
|
if [ "$EXPECT_CROSS" == "true" ]; then
|
||||||
if [ ! -f "$RUNNER_TEMP/cross" ]; then
|
if [ ! -f "$RUNNER_TEMP/cross" ]; then
|
||||||
@ -24,3 +25,25 @@ else
|
|||||||
echo "file output does not match $EXPECT_FILE_RE"
|
echo "file output does not match $EXPECT_FILE_RE"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||||
|
# File on macOS doesn't report whether the binary is stripped or not.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$FILE" =~ "not stripped" ]]; then
|
||||||
|
echo "binary was not stripped"
|
||||||
|
GOT_STRIPPED="false"
|
||||||
|
elif [[ "$FILE" =~ "stripped" ]]; then
|
||||||
|
echo "binary was stripped"
|
||||||
|
GOT_STRIPPED="true"
|
||||||
|
else
|
||||||
|
# On Windows the aarch64 binary's file info doesn't include the word
|
||||||
|
# "stripped" at all.
|
||||||
|
echo "binary was not stripped"
|
||||||
|
GOT_STRIPPED="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$EXPECT_STRIPPED" != "$GOT_STRIPPED" ]; then
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user