Fix detect-targets on ubuntu 20.04, glibc 2.31 (#1379)

* Fix `detect-targets` on ubuntu 20.04, glibc 2.31

Fixed #1375 and fixed #1378

glibc 2.31 does not support `--version`, so we need to detect and
fallback to passing an executable linked with that glibc to check if it
is indeed glibc.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix compilation faillure on ubuntu-20.04

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-09-23 09:55:12 +10:00 committed by GitHub
parent f6e6a2f899
commit efbd20857b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -153,10 +153,18 @@ jobs:
alpine test.sh "$TARGET"
detect-targets-ubuntu-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- name: Build detect-targets
run: cargo build --bin detect-targets
- name: Run test in ubuntu

View file

@ -108,6 +108,19 @@ You are not meant to run this directly.
} else {
None
}
} else if status.code() == Some(127) {
// On Ubuntu 20.04 (glibc 2.31), the `--version` flag is not supported
// and it will exit with status 127.
let status = Command::new(cmd)
.arg("/bin/true")
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.await
.ok()?;
status.success().then_some(Libc::Gnu)
} else {
None
}