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

add native-comp-branch option #188

Closed
wants to merge 15 commits into from
Closed

Conversation

d12frosted
Copy link
Owner

fixes #187

@d12frosted
Copy link
Owner Author

Oh well, I can't test it locally now. So... power of CI?

@glepnir
Copy link

glepnir commented Mar 27, 2020

@d12frosted i saw you add this option with-native-comp-branch does emacs-plusit support? i found this pr build error on CI test.

@d12frosted
Copy link
Owner Author

No, emacs-plus doesn't support it yet. Initially I didn't figure out how to build it. Apparently this can help.

@d12frosted
Copy link
Owner Author

It becomes too much hassle.

@agzam
Copy link

agzam commented Aug 14, 2020

Has anyone built it successfully? I've wasted two days trying to get it right. Darn thing takes forever to compile. I have failed to build it with Cocoa. I need GUI, I can't use terminal only Emacs. Are things really that fast as people claim them to be? It it worth it going through the hassle?

@d12frosted
Copy link
Owner Author

Oh yeah, it takes so much time to compile everything. For me it starts with 105 minutes to compile gcc with jit support.

It seems that for some people these instructions worked fine.

Regarding your question about speed - I am also curious, but never succeeded to build it 😭

@CarlQLange
Copy link

I successfully built and use it, yeah (following the instructions I posted - these should also work). Honestly I haven't seen a lot of improvements in terms of speed, but I switched from Spacemacs to Doom around the same time so it's hard to know for sure. In any case the benchmarks definitely show a huge improvement. Whether that translates to real-life improvements... maybe?

@russell
Copy link

russell commented Sep 8, 2020

I have brushed up this branch to make it compile, that's not to say it's actually working yet. But should i make a WIP PR just so that if someone else wants to try they can? I think the current issues I'm facing are related to upstream bugs. It seems that the binary storage location handling is different when compiling with NS vs without.

@CarlQLange
Copy link

CarlQLange commented Sep 8, 2020

I believe we are waiting on this PR Homebrew/homebrew-core#59134 (or actually, this one? bit weird that they would just take over the PR: Homebrew/homebrew-core#60338) to be merged into Brew so that we have a gcc-with-jit-enabled to build with.

@d12frosted d12frosted force-pushed the feature/native-comp-branch branch 3 times, most recently from 9ad405f to e4c8c19 Compare October 4, 2020 10:13
@d12frosted
Copy link
Owner Author

😿

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>.

@CarlQLange
Copy link

I got this issue as well when compiling from scratch on linux. I wish I could remember my fix - I think I just picked a different emacs commit to build from from a few days prior...

@d12frosted
Copy link
Owner Author

It seems that I need to configure include path. Checkout my latest commit. Still doesn't work though :D

@d12frosted
Copy link
Owner Author

Now I get this:

Last 15 lines from /Users/d12frosted/Library/Logs/Homebrew/emacs-plus-local/02.configure:
checking for X... libraries /usr/X11/lib, headers /usr/X11/include
checking AppKit/AppKit.h usability... no
checking AppKit/AppKit.h presence... yes
configure: WARNING: AppKit/AppKit.h: present but cannot be compiled
configure: WARNING: AppKit/AppKit.h:     check for missing prerequisite headers?
configure: WARNING: AppKit/AppKit.h: see the Autoconf documentation
configure: WARNING: AppKit/AppKit.h:     section "Present But Cannot Be Compiled"
configure: WARNING: AppKit/AppKit.h: proceeding with the compiler's result
configure: WARNING:     ## ------------------------------------ ##
configure: WARNING:     ## Report this to bug-gnu-emacs@gnu.org ##
configure: WARNING:     ## ------------------------------------ ##
checking for AppKit/AppKit.h... no
configure: error: The include files (AppKit/AppKit.h etc) that
are required for a Nextstep build are missing or cannot be compiled.
Either fix this, or re-configure with the option '--without-ns'.

@d12frosted
Copy link
Owner Author

The same error as here :) https://gist.github.com/AllenDang/f019593e65572a8e0aefc96058a2d23e#gistcomment-3412087

Trying clagn as L and I options didn't work

@CarlQLange
Copy link

Wow, I'm surprised you can somehow build with clang and have it still work, I don't really understand how that works!

I haven't seen the AppKit issue before sadly. I wonder if it's just a symlink missing somewhere.

@CarlQLange
Copy link

CarlQLange commented Oct 4, 2020

Ah, the gist mentions different GCC versions which sparked a memory. I think I also had to tweak the version of libgcc I was building with. The version I have installed now is

libgccjit0/focal,now 10.2.0-5ubuntu1~20.04 amd64 [installed]
  GCC just-in-time compilation (shared library)
libgccjit-10-dev/focal,now 10.2.0-5ubuntu1~20.04 amd64 [installed]
  GCC just-in-time compilation (development files)

which I assume is the one I built with.

@d12frosted
Copy link
Owner Author

🤔 But I am getting it dynamically

      gcc_ver = Formula["gcc"].any_installed_version
      gcc_ver_major = gcc_ver.major
      gcc = Formula["gcc"].opt_bin/"gcc-#{gcc_ver_major}"

      ENV["CFLAGS"] = "-I#{Formula["gcc"].include} -I#{Formula["libgccjit"].include}"
      ENV["LDFLAGS"] = "-L#{HOMEBREW_PREFIX}/lib/gcc/#{gcc_ver_major} -I#{Formula["gcc"].include} -I#{Formula["libgccjit"].include}"
      ENV["LIBRARY_PATH"] = "#{HOMEBREW_PREFIX}/lib/gcc/#{gcc_ver_major}:${LIBRARY_PATH:-}"

@d12frosted
Copy link
Owner Author

Nice, I think we are getting closer:

In file included from emacs.c:68:
./bignum.h:25:10: fatal error: 'gmp.h' file not found
#include <gmp.h>

@CarlQLange
Copy link

CarlQLange commented Oct 4, 2020

Sorry, no idea :) Let me just post the relevant bit of the flatpak I eventually got building as well (on pop_os, from https://github.com/fejfighter/pgtk-emacs-flatpak), in case it's somehow helpful.

	{
            "name": "libgccjit",
	    "buildsystem": "autotools",
	    "config-opts": [
		"--with-linker-hash-style=gnu",
		"--enable-checking=release",
		"--enable-host-shared",
		"--enable-languages=jit",
		"--enable-static",
		"--disable-bootstrap",
		"--disable-gcov",
		"--disable-libada",
		"--disable-libgomp",
		"--disable-liboffloadmic",
		"--disable-libquadmath",
		"--disable-libquadmath-support",
		"--disable-libsanitizer",
		"--disable-libssp",
		"--disable-libstdcxx",
		"--disable-libvtv",
		"--disable-lto",
		"--disable-multilib",
		"--disable-shared"
	    ],
            "sources": [
                {
                    "type": "git",
                    "url": "git://gcc.gnu.org/git/gcc.git",
		    "tag": "releases/gcc-10.2.0"
                }
            ],
	    "cleanup": [
		"/include",
		"/lib/debug",
		"/share",
		"/libexec",
		"*.la"
	    ]
        },
        {
            "name": "emacs",
            "buildsystem": "autotools",
            "config-opts": [
                "--with-gnutls",
		"--with-nativecomp",
		"--with-modules",
		"--with-jansson",
		"--with-pgtk",
		"--with-zip",
		"--with-xwidgets"
            ],
            "sources": [
                {
		    "type": "git",
                    "url": "https://github.com/fejfighter/emacs.git",
		    "branch": "pgtk-nativecomp"
                },
                {
                    "type": "patch",
                    "path": "appdata-releases.patch"
                },
                {
                    "type": "patch",
                    "path": "appdata-launchable.patch"
                },
                {
                    "type": "patch",
                    "path": "appdata-content-rating.patch"
                },
                {
                    "type": "patch",
                    "path": "appdata-screenshot-size.patch"
                },
                {
                    "type": "patch",
                    "path": "appdata-name.patch"
                },
	        {
                    "type": "patch",
                    "path": "desktop-rename.patch"
                }
            ],
            "cleanup": [
		"/share/icons/hicolor/scalable/apps/emacs.ico",
                "/share/icons/hicolor/scalable/mimetypes/emacs-document.svg",
                "/share/icons/hicolor/scalable/mimetypes/emacs-document23.svg"
            ]
        }

@d12frosted
Copy link
Owner Author

I've managed to build with the latest commit, but running fails:

λ /usr/local/Cellar/emacs-plus-local/28.0.50/Emacs.app/Contents/MacOS/Emacs 
emacs: dlopen(/usr/local/Cellar/emacs-plus-local/28.0.50/Emacs.app/Contents/MacOS/../native-lisp/28.0.50-x86_64-apple-darwin19.5.0-af8a01811c8f51cae61acd918258fffe/lisp-mode-0189ba85598c041b7504f0a916c04219-1738806322de892570d69dfc55b437c2.eln, 1): image not found

And indeed, there is no native-lisp in the Emacs.app. Will continue digging (though a little bit later).

@CarlQLange
Copy link

CarlQLange commented Oct 4, 2020

Ah, this one is common!

Edit: I misread the error message, so the rest of this comment may not be used, sorry!

The lisp directory gets placed somewhere odd by the build process, but the .app expects it to be inside the app bundle. Most of the time people get around it by symlinking like so:

ln -s /usr/local/opt/gccemacs/share/emacs/28.0.50/lisp /Applications/Emacs.app/Contents/

I expect in your case the actual location of the lisp directory is elsewhere.

@d12frosted
Copy link
Owner Author

d12frosted commented Nov 29, 2020

Ah well, locally it doesn't build because of python installation failures.

Update: this comment was related to another PR. Posted here by mistake.

@d12frosted
Copy link
Owner Author

d12frosted commented Nov 29, 2020

It seems that it works even in the end of install function. But then brew does some magic which breaks Emacs.

In order to reproduce, put system "false" somewhere in the end of install function, but after make install and prefix.install "nextstep/Emacs.app". Then run

$ /usr/local/Cellar/emacs-plus@28/28.0.50/Emacs.app/Contents/MacOS/Emacs -Q

Notice that it works. But once you ask brew to ignore the error, it gets to post install and afterwards emacs doesn't work anymore.

Well, one more step!

@d12frosted
Copy link
Owner Author

Hm... I see logs like

=> Changing dylib ID of /usr/local/Cellar/emacs-plus-local/28.0.50/Emacs.app/Contents/native-lisp/28.0.50-x86_64-apple-darwin20.1.0-f10e7cb1f8775ac8884b227b6e51f168/abbrev-2af30c9ac0795d54ce43b6286aa259ff-a03852565cd14ed2eaa6f4159b530c2e.eln
  from /private/tmp/libgccjit-y8REGV/fake.so
    to /usr/local/opt/emacs-plus-local/Emacs.app/Contents/native-lisp/28.0.50-x86_64-apple-darwin20.1.0-f10e7cb1f8775ac8884b227b6e51f168/fake.so

@daviderestivo
Copy link
Collaborator

It seems that it works even in the end of install function. But then brew does some magic which breaks Emacs.

In order to reproduce, put system "false" somewhere in the end of install function, but after make install and prefix.install "nextstep/Emacs.app". Then run

$ /usr/local/Cellar/emacs-plus@28/28.0.50/Emacs.app/Contents/MacOS/Emacs -Q

Notice that it works. But once you ask brew to ignore the error, it gets to post install and afterwards emacs doesn't work anymore.

Well, one more step!

I'm smashing my head on this since two days :) ...

@iwahbe
Copy link

iwahbe commented Nov 29, 2020

On the most recent version, this fails for me at a SHA256 mismatch

❯ ./build 28 --with-native-comp
==> Downloading https://homebrew.bintray.com/bottles/c-ares-1.17.1.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/bcc766ef22142c2c04b122ea0f2070befdf145693edd77d92676d70af6f561b0--c-ares-1.17.1.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/jemalloc-5.2.1_1.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/dc9654699a1655295a1319ee956e64a6318387e860c95b5c7ed43b71af05a47d--jemalloc-5.2.1_1.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/libev-4.33.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/25986a407604060b345a80ce81f51c69f9632ef16de0474e2efcfc69aaf83f2e--libev-4.33.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/nghttp2-1.42.0.catalina.bottle.1.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/88508f0b5b6fe8f4b6ebafa4ccdf474dc326791958553871b31813a251c9a84d--nghttp2-1.42.0.catalina.bottle.1.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/unbound-1.12.0_1.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/17e648ea023235502b669989b07f73005cb916013c12f2054a34e606277f52da--unbound-1.12.0_1.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/python%403.9-3.9.0_2.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/f40ec7142538a2d124655023300e9ba1c6d01ab20656ab9908a4472e284b5b13--python@3.9-3.9.0_2.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/librsvg-2.50.2.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/ac42f39d9a09c89317808276df7860b16cf04130460c4c5d9d60366f4d6922b8--librsvg-2.50.2.catalina.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/imagemagick-7.0.10-44.catalina.bottle.tar.gz
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/38e739ec1cbdb9ad8ac2589520b5db025fdfd34910d245562ce38989699e82cb--imagemagick-7.0.10-44.catalina.bottle.tar.gz
==> Downloading https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/feature/native-comp-branch/patches/emacs-2
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/d6aa38272a9f2e6925f681c6591e896e9bdfef71409d424d1ac08f99be30daf7--fix-window-role.patch
==> Downloading https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/feature/native-comp-branch/patches/emacs-2
Already downloaded: /Users/ianwahbe/Library/Caches/Homebrew/downloads/48f5e4e5927692c9e6ea2ccecd13440f0c4a59d305dab990c93420bbe6f555a9--system-appearance.patch
Error: SHA256 mismatch
Expected: 22b541e2893171e45b54593f82a0f5d2c4e62b0e4497fc0351fc89108d6f0084
  Actual: b4ccc981e461ac12661fc4cf0ad7211a1dcab61dccf4bd4eee49ca5f7d66c496
    File: /Users/ianwahbe/Library/Caches/Homebrew/downloads/48f5e4e5927692c9e6ea2ccecd13440f0c4a59d305dab990c93420bbe6f555a9--system-appearance.patch
To retry an incomplete download, remove the file above.

@d12frosted
Copy link
Owner Author

I'm smashing my head on this since two days :) ...

Understand why :)

On the most recent version, this fails for me at a SHA256 mismatch

Just delete cached file and it will be good. Unfortunately, brew doesn't have versioning for resources. Apparently we should manually mimic it.

@daviderestivo
Copy link
Collaborator

@d12frosted I have opened an issue on brew GitHub page. Let's see what the developers tell us ... brew uses https://www.rubydoc.info/gems/ruby-macho/ for mangling the dylibs and I suspect a bug there.

@daviderestivo
Copy link
Collaborator

A PR request have been created out of the opened issue: Homebrew/brew#10075. I hope it will be merged soon :)

@daviderestivo
Copy link
Collaborator

@d12frosted This 6ecfa3c should make the trick ;)

@d12frosted
Copy link
Owner Author

@daviderestivo 💯 thank you very much! adding dummy commit to fix CI

@d12frosted
Copy link
Owner Author

status in CI is fake! :) will test it locally and if everything ok, merge it

@d12frosted
Copy link
Owner Author

Yep, locally it builds, so merging!

@d12frosted
Copy link
Owner Author

Merged as d8247e4. CI will fail (I think), but I will tackle it later.

If you encounter any errors, please report them to this thread: #187

@d12frosted d12frosted closed this Dec 22, 2020
@d12frosted d12frosted deleted the feature/native-comp-branch branch December 22, 2020 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

native-comp branch option