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

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Copy link
Contributor Author

semarie commented Nov 22, 2017

@semarie

This comment has been minimized.

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`
@ranma42

This comment has been minimized.

Copy link
Contributor

ranma42 commented Nov 22, 2017

The limitation was introduced in 881a724

EDIT: to fix compilation after #43492

@cuviper

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

semarie commented Nov 23, 2017

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

@cuviper

This comment has been minimized.

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.

@alexcrichton alexcrichton referenced this issue Dec 1, 2017

Open

Move more of src/rustllvm to upstream LLVM #46437

5 of 120 tasks complete
@semarie

This comment has been minimized.

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
You can’t perform that action at this time.