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

Rustc not supported on OS X? #10864

Closed
andrewrynhard opened this issue Nov 7, 2015 · 6 comments · Fixed by #14870
Closed

Rustc not supported on OS X? #10864

andrewrynhard opened this issue Nov 7, 2015 · 6 comments · Fixed by #14870
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin

Comments

@andrewrynhard
Copy link

I have the following default.nix

with import <nixpkgs> {}; {
  rustNightlyEnv = stdenv.mkDerivation {
        name = "rust-nightly-env";

    shellHook = ''
      export PS1="rust-nightly-env > "
    '';

        buildInputs = [
      rustc
      cargo
    ];
  };
}

and when invoking nix-shell . I get

nix-shell .
error: Package ‘rustc-1.3.0’ in ‘/nix/store/vgzx25pwvfagwzadszixah6a7nwy5p0w-nixpkgs-16.03pre71191.a946805/nixpkgs/pkgs/development/compilers/rustc/generic.nix:62’ is not supported on ‘x86_64-darwin’, refusing to evaluate.
For `nixos-rebuild` you can set
  { nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.
For `nix-env` you can add
  { allowBroken = true; }
to ~/.nixpkgs/config.nix.

(use ‘--show-trace’ to show detailed location information)

Is this a bug? How can I get rustc to work on OS X?

@vcunat vcunat added the 6.topic: darwin Running or building packages on Darwin label Nov 7, 2015
@vcunat
Copy link
Member

vcunat commented Nov 7, 2015

Well, apparently it isn't (yet). Which doesn't mean it won't just work, but it might need some changes (I don't know).

@andrewrynhard
Copy link
Author

After stopping by the IRC channel, the issue was found to be with LLVM. First rustc/generic.nix line 65 was modified to platforms = platforms.all;. Similarly cargo was modified. I get the following errors:

error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib" "x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib/rustc_llvm-1bf6e69c.0.o" "-o" "x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib/librustc_llvm-1bf6e69c.dylib" "x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib/rustc_llvm-1bf6e69c.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib" "-l" "std-1bf6e69c" "-L" "x86_64-apple-darwin/rt" "-L" "/nix/store/lzpl4l44nrcn3k1d9yl48jwhcylb71c6-llvm-3.7.0/lib" "-L" "/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/.rust/lib/x86_64-apple-darwin" "-L" "/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/lib/x86_64-apple-darwin" "-Wl,-force_load,x86_64-apple-darwin/rt/librustllvm.a" "-l" "LLVMInterpreter" "-l" "LLVMMCJIT" "-l" "LLVMExecutionEngine" "-l" "LLVMRuntimeDyld" "-l" "LLVMAsmParser" "-l" "LLVMLinker" "-l" "LLVMBitWriter" "-l" "LLVMipo" "-l" "LLVMVectorize" "-l" "LLVMPowerPCDisassembler" "-l" "LLVMPowerPCCodeGen" "-l" "LLVMPowerPCAsmParser" "-l" "LLVMPowerPCDesc" "-l" "LLVMPowerPCInfo" "-l" "LLVMPowerPCAsmPrinter" "-l" "LLVMMipsDisassembler" "-l" "LLVMMipsCodeGen" "-l" "LLVMMipsAsmParser" "-l" "LLVMMipsDesc" "-l" "LLVMMipsInfo" "-l" "LLVMMipsAsmPrinter" "-l" "LLVMAArch64Disassembler" "-l" "LLVMAArch64CodeGen" "-l" "LLVMAArch64AsmParser" "-l" "LLVMAArch64Desc" "-l" "LLVMAArch64Info" "-l" "LLVMAArch64AsmPrinter" "-l" "LLVMAArch64Utils" "-l" "LLVMARMDisassembler" "-l" "LLVMARMCodeGen" "-l" "LLVMARMAsmParser" "-l" "LLVMARMDesc" "-l" "LLVMARMInfo" "-l" "LLVMARMAsmPrinter" "-l" "LLVMX86Disassembler" "-l" "LLVMX86AsmParser" "-l" "LLVMX86CodeGen" "-l" "LLVMSelectionDAG" "-l" "LLVMAsmPrinter" "-l" "LLVMCodeGen" "-l" "LLVMTarget" "-l" "LLVMScalarOpts" "-l" "LLVMProfileData" "-l" "LLVMInstCombine" "-l" "LLVMInstrumentation" "-l" "LLVMTransformUtils" "-l" "LLVMipa" "-l" "LLVMAnalysis" "-l" "LLVMX86Desc" "-l" "LLVMObject" "-l" "LLVMMCParser" "-l" "LLVMBitReader" "-l" "LLVMMCDisassembler" "-l" "LLVMX86Info" "-l" "LLVMX86AsmPrinter" "-l" "LLVMMC" "-l" "LLVMX86Utils" "-l" "LLVMCore" "-l" "LLVMSupport" "-l" "ncurses" "-l" "pthread" "-l" "z" "-l" "m" "-l" "c++" "-l" "System" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib" "-Wl,-install_name,@rpath/librustc_llvm-1bf6e69c.dylib" "-Wl,-rpath,@loader_path/" "-Wl,-rpath,/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-l" "compiler-rt"
note: ld: warning: directory not found for option '-L/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
  "_ffi_type_double", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_pointer", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_sint16", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_void", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_sint64", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_prep_cif", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_sint32", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_sint8", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_type_float", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
  "_ffi_call", referenced from:
      llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) in libLLVMInterpreter.a(ExternalFunctions.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang-3.6: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
/private/var/folders/5d/pqjr3mqj0gqclvqx29wxzhfr0000gn/T/nix-build-rustc-1.4.0.drv-0/rustc-1.4.0-src.tar.gz/mk/target.mk:164: recipe for target 'x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib/stamp.rustc_llvm' failed
make: *** [x86_64-apple-darwin/stage0/lib/rustlib/x86_64-apple-darwin/lib/stamp.rustc_llvm] Error 101
make: *** Waiting for unfinished jobs....
builder for ‘/nix/store/akqi1g0783qpf18gjn463a13xc8iz4wd-rustc-1.4.0.drv’ failed with exit code 2
error: build of ‘/nix/store/akqi1g0783qpf18gjn463a13xc8iz4wd-rustc-1.4.0.drv’ failed
/Users/user/.nix-profile/bin/nix-shell: failed to build all dependencies

@pikajude
Copy link
Contributor

@andrewrynhard @vcunat I have a fix for this but it's based on the sandbox-profiles branch and I'd like that to be merged in first. Just a couple changes are necessary:

  • Build llvm as a shared library on Darwin. This requires NIX_LDFLAGS = "-rpath ${llvm}/lib" to be added to packages that directly link with llvm, which right now are clang and rustc.
  • Allow impure dependencies on /bin/cat, /usr/lib/libedit.3.dylib, and /etc/hosts to rustc. These could all be edited out at some point but it's not worth the effort right now.

Some other non-obvious changes are required to get cargo working properly, and they'll be included in the commit that I eventually make to master (unless you want to cherry-pick my changes now, which I'm happy to make available).

@andrewrynhard
Copy link
Author

@pikajude: I think I can wait for the merge into master. Got caught up with something else for now. Thanks for the fixes!

@andrewrynhard
Copy link
Author

@pikajude have your changes been merged yet?

acowley added a commit to acowley/nixpkgs that referenced this issue Mar 13, 2016
Along with PR NixOS#13879, these patches let julia build and run on
darwin. Using an llvm with shared library support is an idea adopted from
a @pikajude comment here NixOS#10864

The libgit2 change is mechanical to pull in iconv on darwin.

The frameworks are referenced by julia's build system.
@retrry retrry mentioned this issue Apr 21, 2016
7 tasks
@retrry
Copy link
Contributor

retrry commented Apr 21, 2016

@andrewrynhard I created pull request here: #14870, which enables Rust Darwin compatibility. Would be good if you could test it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants