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

target_feature requires embedded LLVM copy to be usable #46181

Closed
semarie opened this issue Nov 22, 2017 · 8 comments
Closed

target_feature requires embedded LLVM copy to be usable #46181

semarie opened this issue Nov 22, 2017 · 8 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-SIMD Area: SIMD (Single Instruction Multiple Data) C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@semarie
Copy link
Contributor

semarie commented Nov 22, 2017

It seems that target_feature requires the embedded LLVM copy to populate the available target_features.

target_features() in src/librustc_trans/llvm_util.rs iterates on whitelisted lists of features, and check for each if the feature is available, using llvm::LLVMRustHasFeature().

The function comes from src/rustllvm/PassWrapper.cpp, and will return always false if LLVM_RUSTLLVM isn't defined. So if the binded LLVM isn't the embedded copy.

I found it when building rustc 1.22 (prestable) as run-pass/sse2 failed. But firefox-57 depends on simd crate and simd uses target_feature: it makes firefox unbuildable in such situation.

As for distro, it is really a common thing to avoid embedded copy of code, it is really annoying.

@semarie
Copy link
Contributor Author

semarie commented Nov 22, 2017

cc @alexcrichton @nagisa

@semarie
Copy link
Contributor Author

semarie commented Nov 22, 2017

the error I have while building stock firefox-57 on openbsd with rustc 1.22:

  --> /data/semarie/repos/openbsd/ports/pobj/firefox-57.0/firefox-57.0/third_party/rust/simd/src/common.rs:17:10
   |
17 | use x86::sse2::common;
   |          ^^^^ Could not find `sse2` in `x86`

@kennytm kennytm added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-SIMD Area: SIMD (Single Instruction Multiple Data) C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 22, 2017
@ranma42
Copy link
Contributor

ranma42 commented Nov 22, 2017

The limitation was introduced in 881a724

EDIT: to fix compilation after #43492

@cuviper
Copy link
Member

cuviper commented Nov 22, 2017

But firefox-57 depends on simd crate and simd uses target_feature:

Isn't simd a nightly-only crate? How can Firefox be using it? It's present in third_party/rust/simd, but I think that's only as a vendored optional dependency for crates like regex.
(It does not appear to be used in Fedora's build of Firefox 57, at least...)

Anyway, AFAIK MCSubtargetInfo::getFeatureTable() and getCPUTable() are currently the only API changes in rust-lang/llvm. This wasn't a big deal when they were only informational, used for rustc --print target-features --print target-cpus. But it's more painful if these now affect actual code use. Have these APIs been proposed upstream to LLVM?

@semarie
Copy link
Contributor Author

semarie commented Nov 23, 2017

it seems the issue was already present with rust-1.21.0: freebsd already saw it: freebsd bug 223300

at openbsd, rust-1.21.0 was compiled with embedded LLVM. this one with system LLVM. so I only saw it now.

about firefox, it seems that firefox explicitely enable the build with simd for performance reason. see firefox 1261841

@semarie
Copy link
Contributor Author

semarie commented Nov 23, 2017

firefox enable nightly features for simd: config/rules.mk#875

@cuviper
Copy link
Member

cuviper commented Nov 23, 2017

Then Firefox is cheating -- but you still have the option to build it without simd, it seems.

@semarie
Copy link
Contributor Author

semarie commented May 15, 2018

with #49428, the problem should be solved. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-SIMD Area: SIMD (Single Instruction Multiple Data) C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

4 participants