-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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: Make gccemacs build on darwin #94637
Conversation
@antifuchs Awesome! And thanks for letting me know 🙂 |
OK, I finally got this to build properly, and it looks like the native-comp emacs branch is working on this Darwin installation:
|
One more thing that is currently failing:
|
9b1eb34
to
1083b43
Compare
So this looks like the default native-compilation |
@@ -251,7 +251,7 @@ postInstall() { | |||
fi | |||
|
|||
if type "install_name_tool"; then | |||
for i in "${!outputLib}"/lib/*.*.dylib; do | |||
for i in "${!outputLib}"/lib/*.*.dylib "${!outputLib}"/lib/*.so.[0-9]; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a bug in gcc buildsystem that they install libgccjit as .so file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this needs to be fixed here: https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/gcc/jit/Make-lang.in#L43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, looks like it. They still make weird linux-soname based assumptions around how the structure works, but I think we could just set this as a make variable (or patch it) to fix. Probably the better way to fix it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They have it conditionals for windows but not for macOS now: https://github.com/gcc-mirror/gcc/blob/229752afe3156a3990dacaedb94c76846cebf132/gcc/jit/Make-lang.in#L48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway if you don't patch the build system would it not be better to rename it from .so to .dylib?
1083b43
to
8620997
Compare
So as far as I can tell, on Darwin you must pass linker options (especially the ones used to find libgccjit) to |
Status update on this:
I'll push changes to make this happen as soon as the scratch branch is on the native-comp feature branch, hopefully the next couple of days! |
The default `strip` invocation tries to strip global symbols from the library, and refuses because those are indirect symbol table references.
This comment has been minimized.
This comment has been minimized.
This changes PATH such that the correct linker can be found to construct .eln files at runtime.
Since Darwin's linker does not understand LIBRARY_PATH, we have to set the library path as explicit linker flags: This requires a very recent feature/native-comp emacs revision, but it runs on Darwin and correctly compiles files at runtime.
It's not necessary to use strip -x otherwise, so let's just use it for the JIT library.
This is the portable way to address the system-appropriate libc, better than conditionalizing by (darwin/GNU) system or using either one.
4334b63
to
ad7a3fb
Compare
That's curious - I could build this derivation just fine on Ubuntu 18.04. |
This way, we don't have to drag clang or binutils/binutils-wrapped into the emacs closure, and can instead rely on using the correct one for the platform we're running on. Co-authored-by: Matthew Bauer <[email protected]>
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.
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.
43baf60
to
04fffd6
Compare
Hi all! Been following the discussion lately, haven't tried it but thanks for all the effort! A question comes to mind, has anyone tried the patch for "emacsMac" here? |
@rcorrear If you mean, will native-compilation (gccemacs) work with the Mitsuharu's emacs-mac repository, the answer is no. Native compilation is currently in a feature branch, and it would be nontrivial to merge mitsuharu's work. You'll likely have to wait until native compilation is merged into emacs. |
@mjlbach yeah, that's what I wanted to know, thanks! |
Apologies if this is an inappropriate place to ask, but does anyone know if there is a cached build of emacsGcc on macOS available? I just tried building it with something like: emacsPackagesNg =
let
emacs-overlay =
import (builtins.fetchTarball https://github.com/nix-community/emacs-overlay/archive/master.tar.gz);
pkgs = import (fetchGit {
url = "https://github.com/NixOS/nixpkgs.git";
rev = "6fc3562432357cdbcbb30804b47feacfac452acb"; # this is this PR's merge commit
}) {
overlays = [ emacs-overlay ];
};
in
pkgs.emacsPackagesNgGen pkgs.emacsGcc; on a 2017 13" MacBook Pro and it was compiling from like 11:30AM - 7:30PM before I Ctrl+C'd it, and even after all that time it was still building LLVM things 😬 |
If you want, you can use my overlay/cachix which has CI for macOS (only on the linked branch). https://github.com/mjlbach/emacs-pgtk-nativecomp-overlay/tree/cleanups |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Motivation for this change
To allow macOS/darwin users to build Emacs with the native-comp feature. These changes are all for problems that on Darwin, result in broken binary installs and failures to resolve the emacs derivation.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)