d12frosted / homebrew-emacs-plus

Emacs Plus formulae for the Homebrew package manager
MIT License
2.38k stars 187 forks source link

[Build Failure]: libgccjit again - emacs-plus@29, osx 14.5, gcc 14.1.0, libgccjit 14.1.0, old intel macbook air6,2 #710

Closed vv111y closed 2 months ago

vv111y commented 3 months ago

Version

emacs-plus@29

Make sure to follow these steps before submitting the issue

What happened?

$ brew install emacs-plus@29 --with-native-comp
Command output

checking for libgccjit.h... yes
configure: error: The installed libgccjit failed to compile and run a test program using
the libgccjit library; see config.log for the details of the failure.
The test program can be found here:
.
You can try compiling it yourself to investigate the issues.
Please report the issue to your distribution if libgccjit was installed
through that.
You can find the instructions on how to compile and install libgccjit from
source on this site:
.

  

brew doctor output

Warning: Some installed casks are deprecated or disabled. You should find replacements for the following casks: buzz cakebrew ethereum-wallet

Warning: Some installed formulae are deprecated or disabled. You should find replacements for the following formulae: binwalk dog hashpump libcroco openssl@1.1 packer tcptrace youtube-dl

Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on those kegs to fail to run properly once built. Run brew link on these: syncthing pycparser cffi numpy

brew config output

HOMEBREW_VERSION: 4.3.17-83-g21979c0 ORIGIN: https://github.com/Homebrew/brew HEAD: 21979c097e1da167a2b091b1395a52d5fc4e3b88 Last commit: 8 hours ago Core tap JSON: 22 Aug 04:35 UTC Core cask tap JSON: 22 Aug 04:35 UTC HOMEBREW_PREFIX: /usr/local HOMEBREW_BROWSER: brave HOMEBREW_CASK_OPTS: [] HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.Skf7AFrHr0/org.xquartz:0 HOMEBREW_EDITOR: vim HOMEBREW_MAKE_JOBS: 4 HOMEBREW_SORBET_RUNTIME: set Homebrew Ruby: 3.3.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.4_1/bin/ruby CPU: quad-core 64-bit haswell Clang: 15.0.0 build 1500 Git: 2.46.0 => /usr/local/bin/git Curl: 8.6.0 => /usr/bin/curl macOS: 14.5-x86_64 CLT: 15.3.0.0.1.1708646388 Xcode: 15.4

Any extra information

this is what I had to do to get a dummy test.c file to work using libgccjit.

gcc -v -o test_jit test_jit.c -I/usr/local/opt/libgccjit/include -L/usr/local/opt/libgccjit/lib/gcc/current -Wl,-rpath,/usr/local/opt/libgccjit/lib/gcc/current -lgccjit

I tried adjusting env in the formula but no go:

# Necessary for libgccjit library discovery
ENV.append "CPATH", "-I#{Formula["libgccjit"].opt_include}" if build.with? "native-comp"
 # ENV.append "LIBRARY_PATH", "-L#{Formula["libgccjit"].opt_lib}" if build.with? "native-comp"
 ENV.append "LIBRARY_PATH", "#{HOMEBREW_PREFIX}/lib/gcc/current" if build.with? "native-comp"
 # ENV.append "LDFLAGS", "-L#{Formula["libgccjit"].opt_lib} -Wl,-rpath,#{Formula["libgccjit"].opt_lib}" if build.with? "native-comp"
ENV.append "LDFLAGS", "-L#{Formula["libgccjit"].opt_lib} -Wl,-rpath,#{Formula["libgccjit"].opt_lib.to_s}" if build.with? "native-comp"
ENV.append "CFLAGS", "-I#{Formula["libgccjit"].opt_include}" if build.with? "native-comp"

from the console.log this is what is stopping it:

5370 |   #include <libgccjit.h>
   1 |       #include <stdlib.h>
   2 |       #include <stdio.h>
   3 |       int
   4 |       main (int argc, char **argv)
   5 |       {
   6 |         gcc_jit_context *ctxt;
   7 |         gcc_jit_result *result;
   8 |         ctxt = gcc_jit_context_acquire ();
   9 |         if (!ctxt)
  10 |           exit (1);
  11 |         gcc_jit_type *int_type =
  12 |           gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
  13 |         gcc_jit_function *func =
  14 |           gcc_jit_context_new_function (ctxt, NULL,
  15 |                                         GCC_JIT_FUNCTION_EXPORTED,
  16 |                                         int_type, "foo", 0, NULL, 0);
  17 |         gcc_jit_block *block = gcc_jit_function_new_block (func, "foo");
  18 |         gcc_jit_block_end_with_return (
  19 |           block,
  20 |           NULL,
  21 |           gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
  22 |         result = gcc_jit_context_compile (ctxt);
  23 |         if (!result)
  24 |           exit (1);
  25 |         typedef int (*fn_type) (void);
  26 |         fn_type foo =
  27 |           (fn_type)gcc_jit_result_get_code (result, "foo");
  28 |         if (!foo)
  29 |           exit (1);
  30 |         if (foo () != 1)
  31 |           exit (1);
  32 |         gcc_jit_context_release (ctxt);
  33 |         gcc_jit_result_release (result);
  34 |         return 0;
  35 |       }
  36 configure:20544: error: The installed libgccjit failed to compile and run a test program using
  37 the libgccjit library; see config.log for the details of the failure.
  38 The test program can be found here:
  39 <https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
  40 You can try compiling it yourself to investigate the issues.
  41 Please report the issue to your distribution if libgccjit was installed
  42 through that.

actually, I tried compiling above and got:

ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
libgccjit.so: error: error invoking gcc driver
d12frosted commented 3 months ago

I have reverted to using super (i.e. default) environment, which could fix your issue. Please try again and let me know if it works or not.

vv111y commented 2 months ago

Working, so far so good. Thank you for the fix.