Skip to content

Cannot build rustc on systems that use musl libc #28667

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

Closed
leo-unglaub opened this issue Sep 25, 2015 · 11 comments
Closed

Cannot build rustc on systems that use musl libc #28667

leo-unglaub opened this issue Sep 25, 2015 · 11 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@leo-unglaub
Copy link

leo-unglaub commented Sep 25, 2015

Hey,
currently it's not possible to build rustc on Alpine Linux because it is based on musl libc. The main problem is that your shipped LLVM version does not contain the patches needed to compile on musl libc.

/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp: In static member function 'static void* llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(const char*)':
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:148:21: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
     EXPLICIT_SYMBOL(stderr);
                     ^
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:141:43: note: in definition of macro 'EXPLICIT_SYMBOL'
    if (!strcmp(symbolName, #SYM)) return &SYM
                                           ^
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:149:21: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
     EXPLICIT_SYMBOL(stdout);
                     ^
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:141:43: note: in definition of macro 'EXPLICIT_SYMBOL'
    if (!strcmp(symbolName, #SYM)) return &SYM
                                           ^
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:150:21: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
     EXPLICIT_SYMBOL(stdin);
                     ^
/tmp/rustc-beta/src/llvm/lib/Support/DynamicLibrary.cpp:141:43: note: in definition of macro 'EXPLICIT_SYMBOL'
    if (!strcmp(symbolName, #SYM)) return &SYM

The following patches are needed for LLVM to build on Alpine Linux: http://git.alpinelinux.org/cgit/aports/tree/main/llvm?id=HEAD

Sadly it is not possible to use the system LLVM version, because Alpine Linux does not ship FileCheck. So that makes it impossible to use ./configure --llvm-root

Thanks and greetings
Leo

Tasks

Preview Give feedback
No tasks being tracked yet.
@steveklabnik steveklabnik added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Sep 25, 2015
@nagisa
Copy link
Member

nagisa commented Sep 25, 2015

We have instructions for building a musl-enabled rustc distribution.

AFAIR we require gnu libc for an otherwise standard build.

@alexcrichton
Copy link
Member

Could the patches for LLVM be merged upstream perhaps? That way we'd just pick up compatibility automatically!

@leo-unglaub
Copy link
Author

@alexcrichton I think they could be merged with upstream. But i actually would prefer it to use the existing LLVM installation instead of rebuilding LLVM over and over again during the rustc build. Why/What do you need FileCheck for? Is it really needed?

@nagisa i have looked at the docs, but i am unable to compile rustc do to the error message i posted above.

@alexcrichton
Copy link
Member

Currently FileCheck is used to run some codegen tests that we have. Did you install LLVM via a package manager? I've found in ubuntu at least that llvm-tools gave binaries like FileCheck which may be useful?

@nagisa
Copy link
Member

nagisa commented Sep 28, 2015

You cannot rely on FileCheck being installed by the distribution. It also could pretty much be made optional IMO.

@leo-unglaub
Copy link
Author

@alexcrichton i looked at all files distributed by Alpine Linux. There is no FileCheck available. I checked other distros as well and not all of then provide that file. Maybe this could be replaced with something more generic?

@alexcrichton
Copy link
Member

Perhaps! It's not super critical that we run our codegen tests in all configurations (we have very few codegen tests right now) so it'd probably just make more sense to have a --disable-codegen-tests configure switch or something like that in which case we wouldn't look for FileCheck

@leo-unglaub
Copy link
Author

So what would be the next steps to get this issue fixed so that Rust then runs on Alpine Linux?

@foutrelis
Copy link

This was reported to us on Arch Linux, asking to ship FileCheck so Rust can be built using the system LLVM. [1] Upstream LLVM seems to believe FileCheck is only used for running LLVM tests. [2]

FileCheck used to be installed by the autotools build system but we have now switched to CMake which is the recommended way to build LLVM these days.

I will comment on the LLVM bug report that Rust uses it for some of its tests; either LLVM needs to install FileCheck for CMake builds or Rust to make it optional.

[1] https://bugs.archlinux.org/task/47510
[2] https://llvm.org/bugs/show_bug.cgi?id=25675

@alexcrichton
Copy link
Member

FileCheck isn't critical to our test suite, I'd be fine doing something like:

  • Add a ./configure option to skip running these tests (but they're still run by default)
  • Skip these tests automatically if a system LLVM is used

@JoshStrobl
Copy link

Stuck with the same issue currently as well.

Solus doesn't ship llvm utils given we don't use the autotools system and with no way to skip the tests, I'm currently stuck delivering the Rust binaries as opposed to building the Rust source and cargo separately (which I'd prefer to do).

Given LLVM being such a bigger part of the system toolchain and thus making it a bit more of a PITA to update to newer versions, a ./configure option in Rust certainly seems like the most optimal short-term solution.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 3, 2016
Our `codegen` test suite requires the LLVM `FileCheck` utility but unfortunately
this isn't always available in all custom LLVM roots (e.g. those specified via
`--llvm-root`). This commit adds a `./configure` option called
`--disable-codegen-tests` which will manually disable running these tests. In
the case that this option is passed we can forgo the need for the `FileCheck`
executable. Note that we still require `FileCheck` by default as we will attempt
to run these tests.

Closes rust-lang#28667
bors added a commit that referenced this issue Apr 3, 2016
mk: Add configure option for disabling codegen tests

Our `codegen` test suite requires the LLVM `FileCheck` utility but unfortunately
this isn't always available in all custom LLVM roots (e.g. those specified via
`--llvm-root`). This commit adds a `./configure` option called
`--disable-codegen-tests` which will manually disable running these tests. In
the case that this option is passed we can forgo the need for the `FileCheck`
executable. Note that we still require `FileCheck` by default as we will attempt
to run these tests.

Closes #28667
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.
Projects
None yet
Development

No branches or pull requests

6 participants