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

OS X: Wrong CMake flag: " LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu" #110

Open
IngwiePhoenix opened this issue Feb 4, 2019 · 5 comments
Labels
maybe-fixed A potential fix has been committed, awaiting confirmation

Comments

@IngwiePhoenix
Copy link

> /Users/Ingwie/Work/Git/mrustc/bin/mrustc lib/libproc_macro/src/lib.rs --crate-name proc_macro --crate-type rlib -g --cfg debug_assertions -O -o output/libproc_macro.hir -L output
cd rustc-1.19.0-src/build && cmake -D LLVM_TARGET_ARCH=x86_64 -D LLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-gnu -D LLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" -D LLVM_ENABLE_ASSERTIONS=OFF -D LLVM_INCLUDE_EXAMPLES=OFF -D LLVM_INCLUDE_TESTS=OFF -D LLVM_INCLUDE_DOCS=OFF -D LLVM_ENABLE_ZLIB=OFF -D LLVM_ENABLE_TERMINFO=OFF -D LLVM_ENABLE_LIBEDIT=OFF -D WITH_POLLY=OFF -D CMAKE_CXX_COMPILER="clang++" -D CMAKE_C_COMPILER="clang" -D CMAKE_BUILD_TYPE=RelWithDebInfo ../src/llvm

When I saw this command floating by on my terminal, I immediately tilted my head - because this is pretty much not correct. On my case, it should be passing x86_64-apple-darwin instead. Any idea why this is happening?

@IngwiePhoenix
Copy link
Author

This happened somewhat later in the build:

[ 87%] Linking CXX shared library ../../lib/libLTO.dylib
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [lib/libLTO.dylib] Error 1
make[2]: *** [tools/lto/CMakeFiles/LTO.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [rustc-1.19.0-src/build/bin/llvm-config] Error 2
[email protected] ~/W/g/mrustc $ 

I don't know how to make this give me verbose output, so this is currently all I have. :)

@thepowersgang
Copy link
Owner

The incorrect target is being passed because the makefile (minicargo.mk) has a semi-hard-coded rustc target of x86_64-unknown-linux-gnu (with no magical autodetection).

It's kinda a moot point at the moment, because OSX builds don't work (linking errors creating the final executable)

@IngwiePhoenix
Copy link
Author

IngwiePhoenix commented Feb 9, 2019

Huh? No. It built perfectly, actually :)

[email protected] ~/W/G/mrustc $ ./bin/mrustc --version
MRustC v0.8.0 master:1a3c5dfc
- Build time: Mon, 04 Feb 2019 00:17:38 +0000
- Commit: 1a3c5dfcab0776c9a9a057303f823cec16386517

Well the target-passing makes sense now. Thanks :)

EDIT
The only thing not working is building rustc using mrustc, though. Looking at the error I posted again, the GNU linker might be expected. I do have a GCC installation - so maybe I can pass the paths to this installation instead, so my main toolchain (Apple's command line tools) isn't used?

CC=/usr/local/opt/gcc@7/bin/gcc
CXX=/usr/local/opt/gcc@7/bin/g++
(?) LD=/usr/local/opt/gcc@7/bin/gcc

The default linker is here: /usr/bin/ld
Looking at it's man-page reveals that it only supports -Z and not -z. Meanwhile, looking at one of my cross-compiler setups:

$ /usr/local/psxsdk/bin/mipsel-unknown-elf-ld --help | grep -- -z
  -z common-page-size=SIZE    Set common page size to SIZE
  -z max-page-size=SIZE       Set maximum page size to SIZE
  -z defs                     Report unresolved symbols in object files
  -z muldefs                  Allow multiple definitions
  -z execstack                Mark executable as requiring executable stack
  -z noexecstack              Mark executable as not requiring executable stack
  -z globalaudit              Mark executable requiring global auditing
  -z combreloc                Merge dynamic relocs into one section and sort
  -z nocombreloc              Don't merge dynamic relocs into one section
  -z global                   Make symbols in DSO available for subsequently
  -z initfirst                Mark DSO to be initialized first at runtime
  -z interpose                Mark object to interpose all DSOs but executable
  -z lazy                     Mark object lazy runtime binding (default)
  -z loadfltr                 Mark object requiring immediate process
  -z nocopyreloc              Don't create copy relocs
  -z nodefaultlib             Mark object not to use default search paths
  -z nodelete                 Mark DSO non-deletable at runtime
  -z nodlopen                 Mark DSO not available to dlopen
  -z nodump                   Mark DSO not available to dldump
  -z now                      Mark object non-lazy runtime binding
  -z origin                   Mark object requiring immediate $ORIGIN
  -z relro                    Create RELRO program header
  -z norelro                  Don't create RELRO program header (default)
  -z separate-code            Create separate code program header
  -z noseparate-code          Don't create separate code program header (default)
  -z common                   Generate common symbols with STT_COMMON type
  -z nocommon                 Generate common symbols with STT_OBJECT type
  -z stack-size=SIZE          Set size of stack segment
  -z text                     Treat DT_TEXTREL in shared object as error
  -z notext                   Don't treat DT_TEXTREL in shared object as error
  -z textoff                  Don't treat DT_TEXTREL in shared object as error

So this is appearently a GNU linker vs. LLVM linker difference... Any workaround here?

@thepowersgang
Copy link
Owner

Not built in - as said, OSX isn't working (I don't have a OSX machine easily accessible, so I can't do much work on it)

The bit that doesn't work isn't building mrustc (that usually works properly), it's building anything with mrustc (see https://travis-ci.org/thepowersgang/mrustc/jobs/490819360)

If you're able to get things working on OSX (particularly working on travis), I'm open to a pull request.

@thepowersgang
Copy link
Owner

There have been quite a few macos improvements recently, have any of these fixed the remaining issues?

The original issue (LLVM_DEFAULT_TARGET_TRIPLE) has been fixed.

@thepowersgang thepowersgang added the maybe-fixed A potential fix has been committed, awaiting confirmation label Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maybe-fixed A potential fix has been committed, awaiting confirmation
Projects
None yet
Development

No branches or pull requests

2 participants