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: Add infrastructure for native-comp #93716

Merged
merged 6 commits into from Jul 24, 2020

Conversation

adisbladis
Copy link
Member

@adisbladis adisbladis commented Jul 23, 2020

Motivation for this change

This is to facilitate the emacsGcc support in https://github.com/nix-community/emacs-overlay.
It's not feasible to add all of this through overrides.

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.

These are required for emacs 27 and above and the nix-community emacs
overlay are adding these via overrides.

Add these already on emacs 26 to be forwards compatible and require
less overrides in the overlay.
@adisbladis adisbladis merged commit ea63a04 into NixOS:master Jul 24, 2020
babariviere added a commit to babariviere/dotfiles that referenced this pull request Jul 27, 2020
@adisbladis adisbladis mentioned this pull request Jul 27, 2020
@antifuchs
Copy link
Contributor

Thanks for getting this merged!

I just tried building the native-comp emacs on darwin (which I know works outside nix; most instructions refer to homebrew), and found two errors: One is fixed by 3a79681 (which fixes installation of libgccjit), and the other is that https://github.com/NixOS/nixpkgs/pull/93716/files#diff-c88608e19b22610f68cf3cce033c0678R69 depends on stdenv.glibc, which doesn't work on Darwin. I'm building a merged set of those two fixes (replacing glibc with libc), and hope to submit a follow-on PR soon: building the world just takes a few hours on this 4-core macbook pro.

@evanrelf
Copy link

@antifuchs Do you think you'll have a PR up soon to add Darwin support? I'm having trouble coming up with a fix on my own.

@antifuchs
Copy link
Contributor

@evanrelf I'm sorry, I didn't manage to make any progress. There's the .libc change that was pointed out on the commit; but so far, I'm failing to compile a libgccjit. I got the error message "symbols referenced by indirect symbol table entries that can't be stripped" building that library, which apparently means you have to run strip -x on macOS... but I couldn't find out where to hook that in.

Maybe we ought to report one or two other issues about Darwin builds there. /:

@antifuchs
Copy link
Contributor

antifuchs commented Aug 3, 2020

@evanrelf after thinking about this more, here's a branch that seems to build libgccjit and is well on the way towards building the world and then emacs (I'm about halfway through building LLVM right now, all four cores on this machine are sweating). Here's the branch: staging...antifuchs:gccemacs-on-darwin - I hope this helps (and most of all, that it works! We're spending a lot of watts on this)

Update, 12 hours later: The change I posted does compile all emacs-gcc's dependencies, but then compilation of emacs itself fails with

checking for dlfunc... no
configure: error: Installed libgccjit has failed passing the smoke test.
You can verify it yourself compiling:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
Please report the issue to your distribution.
Here instructions on how to compile and install libgccjit from source:
<https://gcc.gnu.org/wiki/JIT>.

@evanrelf
Copy link

evanrelf commented Aug 3, 2020

@antifuchs Could it be because stdenv.cc on Darwin is set to clang?

nix-repl> pkgs.stdenv.cc.cc.name
"clang-7.1.0"

You probably need to force it to use gcc explicitly, rather than stdenv.cc.

EDIT: Actually I think I misunderstood the error... it's complaining about libgccjit failing, not the C compiler failing to work with it.

@antifuchs
Copy link
Contributor

@evanrelf my understanding is that you have to compile (nextstep-type) Emacs with clang on darwin because gcc hasn't caught up to the language features yet (or you'd have to build it with X11 GUI - see). I think the build dependencies up to libgccjit work, except the libgccjit dynamic library is installed as libgccjit.so.0.0.1, not as libgccjit.dylib. Emacs's configure script builds the test program with -lgccjit, and the resulting binary (according to otool -L doesn't have the path to the dynamic library coded into it, and fails with "Image not found".

I guess I have to figure out how to install it as a .dylib... or something else.

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.

None yet

4 participants