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

emacs: fix paths for native compilation #98673

Merged
merged 1 commit into from Sep 26, 2020

Conversation

acowley
Copy link
Contributor

@acowley acowley commented Sep 24, 2020

The given paths gives rise to errors such as,

x86_64-unknown-linux-gnu-gcc-9.3.0: fatal error: cannot execute ‘as’: execvp: No such file or directory
compilation terminated.

in the *Async-native-compile-log* buffer.

Fixes nix-community/emacs-overlay#69

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

The given paths gives rise to errors such as,

```
x86_64-unknown-linux-gnu-gcc-9.3.0: fatal error: cannot execute ‘as’: execvp: No such file or directory
compilation terminated.
```

in the `*Async-native-compile-log*` buffer.

Fixes <nix-community/emacs-overlay#69>
acowley referenced this pull request Sep 24, 2020
The -B flag to gcc (and libgccjit) allows us to specify where it can
find things it needs to correctly compile code (both programs and
libraries) without adjusting any environmental flags: So, no need to
wrap the program for a PATH entry containing binutils, and no need to
explicitly pass a linker path anymore.
"${lib.getBin stdenv.cc.bintools.bintools}"
"${lib.getBin stdenv.cc.cc}/bin"
"${lib.getBin stdenv.cc.bintools}/bin"
"${lib.getBin stdenv.cc.bintools.bintools}/bin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests, it looked like libgccjit would search through subdirs for binaries. At least that's what I was led to believe based on the prefix name in the docs. Weirdly enough, it can find the as binaries on my macOS system, and I was pretty certain we tested gccemacs's ability to compile on a Linux machine also, with -B paths sans /bin.

I'm pretty sure your change results in the right directory names, but I'm a bit worried we may be flip-flopping between two solutions that only half fix the problem. Hrm. I can try this change on macOS later this weekend, can check if it continues working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I read those docs differently than you, but I can certainly see the confusion. Give the /bin version a shot to see if it works for you, too. In the overlay issue I linked, you can see that another user was pulling as in via another mechanism, and it's not hard to imagine some as getting onto $PATH through various out-of-band mechanisms.

@antifuchs
Copy link
Contributor

antifuchs commented Sep 25, 2020

So one thought I just had was that it would be really cool to have a test checked into nixpkgs that ensures a gccemacs can produce working .eln files. I'm not sure how that can be done since we get gccemacs from the overlay, but it would make this "will it work / won't it work on [platform]" back and forth so much easier to resolve!

@acowley
Copy link
Contributor Author

acowley commented Sep 25, 2020

Wow, yeah, that does seem to fall into the gap. I guess the overlay should have the test, which would be better than no automated test, even if some bug fixes would need to land here.

@antifuchs
Copy link
Contributor

antifuchs commented Sep 26, 2020

OK, I've compiled emacs-gcc (from current emacs-overlay) with nixpkgs from your branch, running the resulting emacs with env -i /nix/store/vgzsq6q9yclafh9nhbn38cgwvc0a5d4r-emacs-gcc-20200924.0/bin/emacs -q (to clear the $PATH and to have my init file ignored) under macOS.

The resulting exec-path was ("." "/nix/store/vgzsq6q9yclafh9nhbn38cgwvc0a5d4r-emacs-gcc-20200924.0/libexec/emacs/28.0.50/x86_64-apple-darwin19.6.0"), and (getenv "PATH") returned nil, so I'm pretty certain it was in a clean environment.

The resulting emacs could natively-compile a .el file I made, and the resulting .eln file could be loaded.

So, I think your change is good!

Also, agreed re. having that test live in the overlay. I'm not sure how to formulate it, but it would be a really really good thing to have.

@acowley
Copy link
Contributor Author

acowley commented Sep 26, 2020

Thank you for looking into it!

@adisbladis adisbladis merged commit bbecb0e into NixOS:master Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

emacsGcc compilation errors
3 participants