Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: fix build-simd job #436

Merged
merged 1 commit into from
Nov 14, 2022
Merged

CI: fix build-simd job #436

merged 1 commit into from
Nov 14, 2022

Conversation

tarcieri
Copy link
Contributor

The RUSTFLAGS were getting applied to build scripts, which caused them to crash with SIGILL.

According to this issue, RUSTFLAGS won't be applied to build scripts when cross-compiling by passing the --target attribute:

rust-lang/cargo#4423

This attempts to work around the problem by explicitly passing:

--target x86_64-unknown-linux-gnu

The `RUSTFLAGS` were getting applied to build scripts, which caused them
to crash with SIGILL.

According to this issue, RUSTFLAGS won't be applied to build scripts
when cross-compiling by passing the `--target` attribute:

rust-lang/cargo#4423

This attempts to work around the problem by explicitly passing:

    --target x86_64-unknown-linux-gnu
@rozbb
Copy link
Contributor

rozbb commented Nov 14, 2022

This fix works for me, but it kinda sucks that the build is broken this bad. Do you know if anyone upstream knows about this? I guess we can just document in the README that this is how you have to compile with SIMD for now (since it already requires a few steps)

@tarcieri
Copy link
Contributor Author

tarcieri commented Nov 14, 2022

@rozbb I think a less brittle and more permanent fix would be to use runtime CPU feature detection rather than RUSTFLAGS. It would even be possible to run the tests with simd_backend enabled in that case.

But this should be enough to get the build working again.

@rozbb
Copy link
Contributor

rozbb commented Nov 14, 2022

Don't you need the RUSTFLAGS part for codegen? If we want runtime detection, then every build needs to include the AVX2/AVX512 code, no?

@tarcieri
Copy link
Contributor Author

tarcieri commented Nov 14, 2022

For ideal codegen you need RUSTFLAGS, but you can still achieve baseline functionality without it.

Instead you can annotate functions with #[target_feature(enable = "avx...")] and LLVM will still inline across those with the assumption the given features are available.

Such functions must also be annotated unsafe and have the potential to SIGILL if you don't do runtime feature detection.

If we want runtime detection, then every build needs to include the AVX2/AVX512 code, no?

Only if the simd_backend feature is enabled.

@rozbb
Copy link
Contributor

rozbb commented Nov 14, 2022

Ah I see. I assumed the RUSTFLAGS were necessary but I suppose they're not. Just generate the code for everything if simd_backend is enabled. It's only a redundancy of 1 backend, at most, so not bad. Is that right?

@rozbb rozbb merged commit 7d27510 into release/4.0 Nov 14, 2022
@tarcieri tarcieri deleted the ci/fix-build-simd branch November 14, 2022 04:25
@tarcieri
Copy link
Contributor Author

Yeah, you include code for all backends for a particular target architecture, and detect which are available at runtime.

That eliminates the need for most users to enable RUSTFLAGS to take advantage of the backend, and also makes the binary relocatable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants