Skip to content

target_feature requires embedded LLVM copy to be usable #46181

Closed
@semarie

Description

@semarie
Contributor

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.

Activity

semarie

semarie commented on Nov 22, 2017

@semarie
ContributorAuthor
semarie

semarie commented on Nov 22, 2017

@semarie
ContributorAuthor

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`
added
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
A-SIMDArea: SIMD (Single Instruction Multiple Data)
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
on Nov 22, 2017
ranma42

ranma42 commented on Nov 22, 2017

@ranma42
Contributor

The limitation was introduced in 881a724

EDIT: to fix compilation after #43492

cuviper

cuviper commented on Nov 22, 2017

@cuviper
Member

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

semarie commented on Nov 23, 2017

@semarie
ContributorAuthor

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

semarie commented on Nov 23, 2017

@semarie
ContributorAuthor

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

cuviper

cuviper commented on Nov 23, 2017

@cuviper
Member

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

semarie

semarie commented on May 15, 2018

@semarie
ContributorAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cuviper@kennytm@ranma42@semarie

        Issue actions

          target_feature requires embedded LLVM copy to be usable · Issue #46181 · rust-lang/rust