Greetings, and thanks!

The second of the following C lines has ud2 placed after it by the
compiler when optimizing:

  vs_push(make_fixnum((ufixnum)data_start));
  vs_push(make_fixnum((ufixnum)data_start+(real_maxpage<<PAGEWIDTH)));

According to

https://stackoverflow.com/questions/21529308/why-does-clang-generate-ud2-opcode-on-osx

this should produce a compile time warning with -Wall (which you should
have) on gbc.c -- was there one?

All I can imagine at present is a signed/unsigned argument mismatch --
you might want to try replacing ufixnum with fixnum in the relevant line
and see if it goes away, though I'm sure there are other instances if
this is so.

Should only appear at -O2, and there should be a specific optimization
flag (i.e. -fno-cool-optimization) that should pinpoint the issue.  If
it points to a valid and elsewhere reproducible problem we can of course
fix it in the code.

Take care,

"Chun Tian (binghe)" <binghe.l...@gmail.com> writes:

> Greetings, and thanks for your kind help.
>
> I'm using macOS Sonoma (14.3.1) with Xcode 15.2 (Apple clang version
> 15.0.0 (clang-1500.1.0.2.5)).
>
> Please find the following disassemble outputs:
>
> (lldb) disassemble
> raw_pre_gcl`siLheap_report:
>     0x1000aa820 <+0>:   pushq  %rbp
>     0x1000aa821 <+1>:   movq   %rsp, %rbp
>     0x1000aa824 <+4>:   pushq  %r15
>     0x1000aa826 <+6>:   pushq  %r14
>     0x1000aa828 <+8>:   pushq  %rbx
>     0x1000aa829 <+9>:   pushq  %rax
>     0x1000aa82a <+10>:  leaq   0x65bf1f(%rip), %rbx      ; vs_top
>     0x1000aa831 <+17>:  movq   (%rbx), %rax
>     0x1000aa834 <+20>:  leaq   0x65bf05(%rip), %rcx      ; vs_base
>     0x1000aa83b <+27>:  cmpq   (%rcx), %rax
>     0x1000aa83e <+30>:  je     0x1000aa84a               ; <+42> at gbc.c
>     0x1000aa840 <+32>:  xorl   %edi, %edi
>     0x1000aa842 <+34>:  callq  0x100010ea0               ;
> check_arg_failed at error.c:400
>     0x1000aa847 <+39>:  movq   (%rbx), %rax
>     0x1000aa84a <+42>:  movabsq $-0x6000000000000000, %r15 ; imm =
> 0xA000000000000000
>     0x1000aa854 <+52>:  leaq   0x1e31d(%rip), %rcx       ; vs_limit
>     0x1000aa85b <+59>:  cmpq   (%rcx), %rax
>     0x1000aa85e <+62>:  jae    0x1000aa870               ; <+80> at
> gbc.c:1277:3
>     0x1000aa860 <+64>:  leaq   0x8(%rax), %rcx
>     0x1000aa864 <+68>:  movq   %rcx, (%rbx)
>     0x1000aa867 <+71>:  leaq   0x40(%r15), %rcx
>     0x1000aa86b <+75>:  movq   %rcx, (%rax)
>     0x1000aa86e <+78>:  jmp    0x1000aa875               ; <+85> at
> gbc.c:1278:3
>     0x1000aa870 <+80>:  callq  0x100009940               ; vs_overflow
> at main.c:847
>     0x1000aa875 <+85>:  movq   (%rbx), %rax
>     0x1000aa878 <+88>:  leaq   0x8(%rax), %rcx
>     0x1000aa87c <+92>:  movq   %rcx, (%rbx)
>     0x1000aa87f <+95>:  leaq   0x1000(%r15), %rcx
>     0x1000aa886 <+102>: movq   %rcx, (%rax)
>     0x1000aa889 <+105>: leaq   0x44c28(%rip), %r14       ; data_start
>     0x1000aa890 <+112>: movq   (%r14), %rax
>     0x1000aa893 <+115>: movabsq $0x2000000000000000, %rcx ; imm =
> 0x2000000000000000
>     0x1000aa89d <+125>: addq   %rax, %rcx
>     0x1000aa8a0 <+128>: shrq   $0x3e, %rcx
>     0x1000aa8a4 <+132>: jne    0x1000aa8ab               ; <+139> at
> gbc.c:1279:3
>     0x1000aa8a6 <+134>: addq   %r15, %rax
>     0x1000aa8a9 <+137>: jmp    0x1000aa8b3               ; <+147> at
> gbc.c:1279:3
>     0x1000aa8ab <+139>: movq   %rax, %rdi
>     0x1000aa8ae <+142>: callq  0x10007fe60               ; make_fixnum1
> at number.c:99
>     0x1000aa8b3 <+147>: movq   (%rbx), %rcx
>     0x1000aa8b6 <+150>: leaq   0x8(%rcx), %rdx
>     0x1000aa8ba <+154>: movq   %rdx, (%rbx)
>     0x1000aa8bd <+157>: movq   %rax, (%rcx)
>     0x1000aa8c0 <+160>: leaq   0x662121(%rip), %rax      ; real_maxpage
>     0x1000aa8c7 <+167>: movq   (%rax), %rdi
>     0x1000aa8ca <+170>: shlq   $0xc, %rdi
>     0x1000aa8ce <+174>: addq   (%r14), %rdi
>     0x1000aa8d1 <+177>: callq  0x10007fe60               ; make_fixnum1
> at number.c:99
> ->  0x1000aa8d6 <+182>: ud2
>
> (lldb) disassemble --pc
> raw_pre_gcl`siLheap_report:
> ->  0x1000aa8d6 <+182>: ud2
>     0x1000aa8d8 <+184>: nopl   (%rax,%rax)
>
> raw_pre_gcl`siLreset_gbc_count:
>     0x1000aa8e0 <+0>:   pushq  %rbp
>     0x1000aa8e1 <+1>:   movq   %rsp, %rbp
>
> According to another Internet articles [1], "Apple's system
> libraries/frameworks also use ud2 as a sort of assert/abort", thus I
> think the "ud2" itself seems not an issue. It's how the instruction flow
> leads to "ud2" matters.
>
> P.S. My Apple hardware is a bit wired. On Catalina or even Snow Leopard
> (10.6), GCL 2.6.14 is already available from MacPorts. But if I try to
> build the GCL package locally in my machine, I think the same crashing
> will happen - and my two MacBook Pro (both are 2019 Intel chips but
> slightly different main frequencies) have the same behavior.  This
> happens only when building GCL, which is somehow particular.
>
> P.S. Given the terrible experience with macOS Sonoma, I think I will
> soon re-install one of my laptops back to Catalina.
>
> Chun
>
> [1]
> https://stackoverflow.com/questions/60898734/illegal-instruction-ud2-when-running-application-with-xcode-as-root-on-macos
>
> On 09/02/24 13:15, Camm Maguire wrote:
>> Greetings, and thanks again so much as always for your helpful feedback.
>> 
>> You were right about brew on my Catalina -- I have disabled these and am
>> testing against the Macports gmp now.
>> 
>> I've committed a stdint.h fix and a gmp.h location detection fix for
>> you.  Building with cc/clang now and all appears to work out of the box
>> with the right environment settings.  In particular, I cannot reproduce
>> the issue you list here.
>> 
>> I would do a disassemble at this point in lldb and post the results.  Is
>> this Catalina?  Perhaps disable C optimization too, either through
>> CFLAGS or --enable-debug to configure.
>> 
>> Take care,
>> 
>> 
>> "Chun Tian (binghe)" <binghe.l...@gmail.com> writes:
>> 
>>> Greetings!
>>>
>>> Ah, I didn't know these environment variables at all. Now I have put
>>> them into my ~/.profile. Thanks.
>>>
>>> After using them, now the previous issues about gmp.h disappeared. Then
>>> I met the issue, which was the reason that I chose GCC 13 over Apple
>>> clang, that "raw_pre_gcl" crashed (Illegal instruction) when doing
>>> (init-system). This time I added CFLAGS=-g when building, run
>>> "raw_pre_gcl" by lldb (LLVM debugger) and try to manually evaluate the
>>> "foo" script line by one, until (init-system):
>>>
>>>> (defun make-package (name &key nicknames use)
>>>>   (si::make-package-int name nicknames use))
>>>>
>>>> (make-package :s :use '(:cl))
>>>> (make-package :compiler :use '(:cl :si :s))
>>>> (make-package :sloop :use '(:cl))
>>>> (make-package :ansi-loop :use'(:cl))
>>>> (make-package :defpackage :use '(:cl))
>>>> (make-package :tk :use '(:cl :sloop))
>>>> (make-package :fpe :use '(:cl))
>>>> (make-package :cltl1-compat)
>>>>
>>>> (in-package :system)
>>>> (use-package '(:fpe :s :gmp))
>>>>
>>>> (export 'si::(object double cnum system cmp-inline cmp-eval 
>>>> type-propagator c1no-side-effects defcfun clines defentry) :si);FIXME
>>>>
>>>> (setq *features* (cons :raw-image *features*))
>>>> (init-system)
>>>
>>> And this is the backtrace:
>>>
>>>> SYSTEM>(init-system)
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_s.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_sf.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_rm.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_dl.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_fle.lsp
>>>> loading 
>>>> /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_defmacro.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_hash.lsp
>>>> loading 
>>>> /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_evalmacros.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_module.lsp
>>>> loading /Volumes/CaseSensitive/Lisp/gcl/gcl/unixport/../lsp/gcl_predlib.lsp
>>>> Process 22566 stopped
>>>> * thread #1, queue = 'com.apple.main-thread', stop reason = 
>>>> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
>>>>     frame #0: 0x00000001000aa8d6 raw_pre_gcl`siLheap_report at gbc.c:0:3 
>>>> [opt]
>>>>    1268    }
>>>>    1269    
>>>>    1270    static void
>>>> -> 1271    FFN(siLheap_report)(void) {
>>>>    1272    
>>>>    1273      int i;
>>>>    1274      
>>>> Note: this address is compiler-generated code in function siLheap_report 
>>>> that has no source code associated with it.
>>>> Target 0: (raw_pre_gcl) stopped.
>>>> warning: raw_pre_gcl was compiled with optimization - stepping may behave 
>>>> oddly; variables may not be available.
>>>> (lldb) bt
>>>> * thread #1, queue = 'com.apple.main-thread', stop reason = 
>>>> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
>>>>   * frame #0: 0x00000001000aa8d6 raw_pre_gcl`siLheap_report at gbc.c:0:3 
>>>> [opt]
>>>>     frame #1: 0x0000000100059586 
>>>> raw_pre_gcl`fSeval_src(first=<unavailable>) at eval.c:963:29 [opt]
>>>>     frame #2: 0x0000000100056f86 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n(f=<unavailable>, n=1, x=<unavailable>) at apply_n.h:6:19 [opt]
>>>>     frame #3: 0x0000000100056f80 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=<unavailable>) at 
>>>> apply_n.h:79:38 [opt]
>>>>     frame #4: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=<unavailable>) at eval.c:74:10 [opt]
>>>>     frame #5: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x0000000100305928) at eval.c:96:7 [opt]
>>>>     frame #6: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #7: 0x00000001000581fa raw_pre_gcl`eval [inlined] 
>>>> funcall_no_event(fun=0x0000000102ed2040) at eval.c:414:5 [opt]
>>>>     frame #8: 0x00000001000581cb raw_pre_gcl`eval(form=<unavailable>) at 
>>>> eval.c:762:4 [opt]
>>>>     frame #9: 0x0000000100064635 
>>>> raw_pre_gcl`Fmultiple_value_list(form=0x0000000102f061c0) at 
>>>> multival.c:68:2 [opt]
>>>>     frame #10: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f061a0) at eval.c:707:3 [opt]
>>>>     frame #11: 0x00000001000580e3 
>>>> raw_pre_gcl`eval(form=0x0000000102f061d0) at eval.c:747:3 [opt]
>>>>     frame #12: 0x00000001000580e3 
>>>> raw_pre_gcl`eval(form=0x0000000102f061e0) at eval.c:747:3 [opt]
>>>>     frame #13: 0x00000001000580e3 
>>>> raw_pre_gcl`eval(form=0x0000000102f061f0) at eval.c:747:3 [opt]
>>>>     frame #14: 0x00000001000580e3 
>>>> raw_pre_gcl`eval(form=0x0000000102f06410) at eval.c:747:3 [opt]
>>>>     frame #15: 0x0000000100029fa0 
>>>> raw_pre_gcl`Fprogn(body=0x0000000102f06460) at prog.c:250:4 [opt]
>>>>     frame #16: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f06450) at eval.c:707:3 [opt]
>>>>     frame #17: 0x0000000100059c64 raw_pre_gcl`ieval(x=<unavailable>) at 
>>>> eval.c:1070:3 [opt]
>>>>     frame #18: 0x0000000100036fec raw_pre_gcl`load(s="lsp") at 
>>>> file.d:1701:3 [opt]
>>>>     frame #19: 0x00000001000bbd98 raw_pre_gcl`lsp_init(a=<unavailable>, 
>>>> b=<unavailable>) at sys.c:75:3 [opt] [artificial]
>>>>     frame #20: 0x00000001000bbf05 
>>>> raw_pre_gcl`gcl_init_system(no_init=<unavailable>) at sys_init.c:51:3 [opt]
>>>>     frame #21: 0x0000000100009dc3 raw_pre_gcl`siLinit_system at 
>>>> main.c:1055:3 [opt]
>>>>     frame #22: 0x0000000100059586 
>>>> raw_pre_gcl`fSeval_src(first=<unavailable>) at eval.c:963:29 [opt]
>>>>     frame #23: 0x0000000100056f86 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n(f=<unavailable>, n=1, x=<unavailable>) at apply_n.h:6:19 [opt]
>>>>     frame #24: 0x0000000100056f80 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=<unavailable>) at 
>>>> apply_n.h:79:38 [opt]
>>>>     frame #25: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=<unavailable>) at eval.c:74:10 [opt]
>>>>     frame #26: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x00000001003058d0) at eval.c:96:7 [opt]
>>>>     frame #27: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #28: 0x00000001000581fa raw_pre_gcl`eval [inlined] 
>>>> funcall_no_event(fun=0x0000000102edf400) at eval.c:414:5 [opt]
>>>>     frame #29: 0x00000001000581cb raw_pre_gcl`eval(form=<unavailable>) at 
>>>> eval.c:762:4 [opt]
>>>>     frame #30: 0x000000010005936b raw_pre_gcl`fLeval(x0=<unavailable>) at 
>>>> eval.c:866:3 [opt]
>>>>     frame #31: 0x0000000100056f6a 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=0x00000001003058a8) at 
>>>> apply_n.h:79:74 [opt]
>>>>     frame #32: 0x0000000100056f5a 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=0x00000001003058a8) at eval.c:74:10 [opt]
>>>>     frame #33: 0x0000000100056f5a 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x00000001003058a8) at eval.c:96:7 [opt]
>>>>     frame #34: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #35: 0x00000001000581fa raw_pre_gcl`eval [inlined] 
>>>> funcall_no_event(fun=0x0000000102e996a0) at eval.c:414:5 [opt]
>>>>     frame #36: 0x00000001000581cb raw_pre_gcl`eval(form=<unavailable>) at 
>>>> eval.c:762:4 [opt]
>>>>     frame #37: 0x0000000100029fa0 
>>>> raw_pre_gcl`Fprogn(body=0x0000000102f0b0d0) at prog.c:250:4 [opt]
>>>>     frame #38: 0x000000010003e077 raw_pre_gcl`Flocally(body=<unavailable>) 
>>>> at toplevel.c:205:2 [opt]
>>>>     frame #39: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0b050) at eval.c:707:3 [opt]
>>>>     frame #40: 0x0000000100064635 
>>>> raw_pre_gcl`Fmultiple_value_list(form=0x0000000102f0b0e0) at 
>>>> multival.c:68:2 [opt]
>>>>     frame #41: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0b040) at eval.c:707:3 [opt]
>>>>     frame #42: 0x000000010008e709 
>>>> raw_pre_gcl`let_bind(body=0x0000000102f0b2b0, start=0x0000000100305858, 
>>>> end=0x0000000100305878) at bind.c:705:3 [opt]
>>>>     frame #43: 0x000000010002b81c 
>>>> raw_pre_gcl`Flet(form=0x0000000102f0b110) at let.c:79:9 [opt]
>>>>     frame #44: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0b020) at eval.c:707:3 [opt]
>>>>     frame #45: 0x0000000100029fa0 
>>>> raw_pre_gcl`Fprogn(body=0x0000000102f0b4b0) at prog.c:250:4 [opt]
>>>>     frame #46: 0x0000000100049c00 
>>>> raw_pre_gcl`Fcatch(args=0x0000000102f0aba0) at catch.c:47:3 [opt]
>>>>     frame #47: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab90) at eval.c:707:3 [opt]
>>>>     frame #48: 0x00000001000b7b18 
>>>> raw_pre_gcl`Fwhen(form=0x0000000102f0b4c0) at conditional.c:150:2 [opt]
>>>>     frame #49: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab80) at eval.c:707:3 [opt]
>>>>     frame #50: 0x0000000100025e73 
>>>> raw_pre_gcl`Floop(form=0x0000000102f0b5b0) at iteration.c:58:3 [opt]
>>>>     frame #51: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab70) at eval.c:707:3 [opt]
>>>>     frame #52: 0x0000000100029fa0 
>>>> raw_pre_gcl`Fprogn(body=0x0000000102f0b5c0) at prog.c:250:4 [opt]
>>>>     frame #53: 0x0000000100049c00 
>>>> raw_pre_gcl`Fcatch(args=0x0000000102f0ab60) at catch.c:47:3 [opt]
>>>>     frame #54: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab50) at eval.c:707:3 [opt]
>>>>     frame #55: 0x00000001000b7b18 
>>>> raw_pre_gcl`Fwhen(form=0x0000000102f0b5e0) at conditional.c:150:2 [opt]
>>>>     frame #56: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab40) at eval.c:707:3 [opt]
>>>>     frame #57: 0x0000000100025e3c 
>>>> raw_pre_gcl`Floop(form=0x0000000102f0b610) at iteration.c:52:3 [opt]
>>>>     frame #58: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0ab30) at eval.c:707:3 [opt]
>>>>     frame #59: 0x0000000100029fa0 
>>>> raw_pre_gcl`Fprogn(body=0x0000000102f0b620) at prog.c:250:4 [opt]
>>>>     frame #60: 0x000000010002b82f 
>>>> raw_pre_gcl`Flet(form=0x0000000102f0a660) at let.c:83:2 [opt]
>>>>     frame #61: 0x0000000100057f14 
>>>> raw_pre_gcl`eval(form=0x0000000102f0a3d0) at eval.c:707:3 [opt]
>>>>     frame #62: 0x00000001000577e4 raw_pre_gcl`funcall(fun=<unavailable>) 
>>>> at eval.c:386:2 [opt]
>>>>     frame #63: 0x000000010005958d 
>>>> raw_pre_gcl`fSeval_src(first=<unavailable>) at eval.c:963:60 [opt]
>>>>     frame #64: 0x0000000100056f86 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n(f=<unavailable>, n=1, x=<unavailable>) at apply_n.h:6:19 [opt]
>>>>     frame #65: 0x0000000100056f80 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=<unavailable>) at 
>>>> apply_n.h:79:38 [opt]
>>>>     frame #66: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=<unavailable>) at eval.c:74:10 [opt]
>>>>     frame #67: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x00000001003057c0) at eval.c:96:7 [opt]
>>>>     frame #68: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #69: 0x00000001000581fa raw_pre_gcl`eval [inlined] 
>>>> funcall_no_event(fun=0x0000000102f1a190) at eval.c:414:5 [opt]
>>>>     frame #70: 0x00000001000581cb raw_pre_gcl`eval(form=<unavailable>) at 
>>>> eval.c:762:4 [opt]
>>>>     frame #71: 0x000000010005781c raw_pre_gcl`funcall(fun=<unavailable>) 
>>>> at eval.c:386:2 [opt]
>>>>     frame #72: 0x000000010005958d 
>>>> raw_pre_gcl`fSeval_src(first=<unavailable>) at eval.c:963:60 [opt]
>>>>     frame #73: 0x0000000100056f86 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n(f=<unavailable>, n=1, x=<unavailable>) at apply_n.h:6:19 [opt]
>>>>     frame #74: 0x0000000100056f80 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=<unavailable>) at 
>>>> apply_n.h:79:38 [opt]
>>>>     frame #75: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=<unavailable>) at eval.c:74:10 [opt]
>>>>     frame #76: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x0000000100305798) at eval.c:96:7 [opt]
>>>>     frame #77: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #78: 0x00000001000581fa raw_pre_gcl`eval [inlined] 
>>>> funcall_no_event(fun=0x0000000102f1a2b0) at eval.c:414:5 [opt]
>>>>     frame #79: 0x00000001000581cb raw_pre_gcl`eval(form=<unavailable>) at 
>>>> eval.c:762:4 [opt]
>>>>     frame #80: 0x00000001000577e4 raw_pre_gcl`funcall(fun=<unavailable>) 
>>>> at eval.c:386:2 [opt]
>>>>     frame #81: 0x000000010005958d 
>>>> raw_pre_gcl`fSeval_src(first=<unavailable>) at eval.c:963:60 [opt]
>>>>     frame #82: 0x0000000100056f86 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n(f=<unavailable>, n=1, x=<unavailable>) at apply_n.h:6:19 [opt]
>>>>     frame #83: 0x0000000100056f80 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> c_apply_n_fun(fun=<unavailable>, n=<unavailable>, b=<unavailable>) at 
>>>> apply_n.h:79:38 [opt]
>>>>     frame #84: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce [inlined] 
>>>> quick_call_function_vec(fun=<unavailable>, n=<unavailable>, 
>>>> b=<unavailable>) at eval.c:74:10 [opt]
>>>>     frame #85: 0x0000000100056f71 
>>>> raw_pre_gcl`quick_call_function_vec_coerce(fun=<unavailable>, 
>>>> n=<unavailable>, b=0x0000000100305770) at eval.c:96:7 [opt]
>>>>     frame #86: 0x00000001000570fb 
>>>> raw_pre_gcl`quick_call_function(fun=<unavailable>) at eval.c:191:11 [opt]
>>>>     frame #87: 0x00000001000574d3 
>>>> raw_pre_gcl`funcall(fun=0x0000000102f1a2e0) at eval.c:256:7 [opt]
>>>>     frame #88: 0x00000001000093b2 raw_pre_gcl`main(argc=<unavailable>, 
>>>> argv=<unavailable>, envp=<unavailable>) at main.c:651:5 [opt]
>>>>     frame #89: 0x00007ff806d40386 dyld`start + 1942
>>>
>>> By searching on Internet [1], I think perhaps the clang compiler is
>>> given wrong architecture parameters, which caused it to generate CPU
>>> instructs not supported by my CPU. But the involved GCC command line
>>> seems clean:
>>>
>>> gcc -DINICOMP -DNO_DEFUN -g -fsigned-char -pipe -fcommon
>>> -fno-builtin-malloc -fno-builtin-free -fno-PIE -fno-pie -fno-PIC
>>> -fno-pic -Wall -Wno-builtin-requires-header -Wno-empty-body
>>> -Wno-self-assign -Wno-unused-but-set-variable
>>> -Wno-incomplete-setjmp-declaration -m64 ...
>>>
>>> If I used GCC 13, there's no such issues (but new issues occur later).
>>> It's a bit strange. What do I miss here?
>>>
>>> --Chun
>>>
>>> [1]
>>> https://stackoverflow.com/questions/53396370/exc-bad-instruction-code-exc-i386-invop-subcode-0x0-underlying-causes
>>>
>>> On 09/02/24 03:32, Camm Maguire wrote:
>>>> Greetings!  I was always taught the canonical way to do this was
>>>>
>>>> export C_INCLUDE_PATH=/opt/local/include
>>>> export LIBRARY_PATH=/opt/local/lib
>>>>
>>>> ./configure && make
>>>>
>>>> This seems to work on my Catalina box with the aforementioned commit.  I
>>>> will try a git pull shortly.
>>>>
>>>> Please let me know if this does not work for you.
>>>>
>>>> Take care,
>>>>
>>>> "Chun Tian (binghe)" <binghe.l...@gmail.com> writes:
>>>>
>>>>> Greetings,
>>>>>
>>>>> thanks for your explanation about the <stdint.h> issue. I will take a
>>>>> look at the regexp you mentioned and see if I can provide a patch.
>>>>>
>>>>> Regarding to external gmp, in my system the GMP library and headers are
>>>>> installed (through MacPorts) at /opt/local/lib and /opt/local/include. I
>>>>> think when I'm using GCC 13, these directories are automatically used.
>>>>> But when I'm compiling with Apple's clang from Xcode, I have to let
>>>>> clang know these directories. However, the following "standard" way
>>>>> doesn't help:
>>>>>
>>>>> export CFLAGS=-I/opt/local/include
>>>>> export LDFLAGS=-L/opt/local/lib
>>>>>
>>>>> With the above environment variables, and with --enable-dynsysgmp when
>>>>> calling ./configure of GCL, I still got the following error messages
>>>>> saying system GMP cannot be used:
>>>>>
>>>>>> checking for gmp.h... yes
>>>>>> checking for __gmpz_init in -lgmp... yes
>>>>>> checking for external gmp version... good
>>>>>> foo.c:1:10: fatal error: 'gmp.h' file not found
>>>>>> #include "gmp.h"
>>>>>>          ^~~~~~~
>>>>>> 1 error generated.
>>>>>> Cannot use dynamic gmp lib
>>>>>> checking doing configure in gmp directory... 
>>>>>> #
>>>>>> #
>>>>>> # -------------------
>>>>>> # Subconfigure of GMP
>>>>>> #
>>>>>> #
>>>>>
>>>>> By looking at your ways of detecting GMP in configure.in:
>>>>>
>>>>>> if test "$enable_dynsysgmp" != "no" ; then
>>>>>>     AC_CHECK_HEADERS(
>>>>>>  [gmp.h],
>>>>>>  [AC_CHECK_LIB(
>>>>>>          [gmp],[__gmpz_init],
>>>>>>          [AC_MSG_CHECKING([for external gmp version])
>>>>>>           AC_RUN_IFELSE(
>>>>>>               [AC_LANG_PROGRAM(
>>>>>>                       [[
>>>>>>                           #include <gmp.h>
>>>>>>                       ]],
>>>>>>                       [[
>>>>>>                           #if __GNU_MP_VERSION > 3
>>>>>>                           return 0;
>>>>>>                           #else
>>>>>>                           return -1;
>>>>>>                           #endif
>>>>>>                       ]])],
>>>>>>               [AC_MSG_RESULT([good])
>>>>>>                TLIBS="$TLIBS -lgmp"
>>>>>>                echo "#include \"gmp.h\"" >foo.c
>>>>>>                echo "int main() {return 0;}" >>foo.c
>>>>>>                MP_INCLUDE=`cpp foo.c | $AWK '/(\/|\\\\)gmp.h/ {if (!i) 
>>>>>> print $3;i=1}' | tr -d '"'`
>>>>>>                rm -f foo.c])])])
>>>>>>
>>>>>>     if test "$MP_INCLUDE" = "" ; then
>>>>>>  AC_MSG_RESULT([Cannot use dynamic gmp lib])
>>>>>>     fi
>>>>>>
>>>>>> fi
>>>>>
>>>>> I think, when the command "cpp foo.c" was getting called, the "cpp"
>>>>> (from Xcode) program still doesn't know the location of GMP headers,
>>>>> unless "cpp $CFLAGS" is used instead. My following manual tests
>>>>> confirmed my guess:
>>>>>
>>>>> $ echo "#include \"gmp.h\"" >foo.c
>>>>> $ echo "int main() {return 0;}" >>foo.c
>>>>> $ cpp foo.c | $AWK '/(\/|\\\\)gmp.h/ {if (!i) print $3;i=1}' | tr -d '"'
>>>>> foo.c:1:10: fatal error: 'gmp.h' file not found
>>>>> #include "gmp.h"
>>>>>          ^~~~~~~
>>>>> 1 error generated.
>>>>> $ cpp $CFLAGS foo.c | $AWK '/(\/|\\\\)gmp.h/ {if (!i) print $3;i=1}' |
>>>>> tr -d '"'
>>>>> /opt/local/include/gmp.h
>>>>>
>>>>> Therefore, I think you should at least put $CFLAGS inside the above
>>>>> configure.in code pieces, to handle non-standard position of GMP headers
>>>>> given by CFLAGS.
>>>>>
>>>>> P.S. in you macOS Catalina environment, if you have GMP libraries
>>>>> installed at /usr/local, that must be installed from Homebrew. I suggest
>>>>> completely removing Homebrew because the installation location of
>>>>> Homebrew has moved to /opt/ in higher versions of macOS. Its advantage
>>>>> of staying at the "default" directory (/usr/local) is no more.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Chun TIAN
>>>>>
>>>>> On 08/02/24 02:31, Camm Maguire wrote:
>>>>>> Greetings, and thannks as always for your feedback.
>>>>>>
>>>>>> "Chun Tian (binghe)" <binghe.l...@gmail.com> writes:
>>>>>>
>>>>>>> Greetings,
>>>>>>>
>>>>>>> In the commit dc9eba0760dedcd3d042a408e715b38ac2222aa3 [1], I saw   the
>>>>>>> following line from gcl/h/compbas2.h was removed:
>>>>>>>
>>>>>>> diff --git a/gcl/h/compbas2.h b/gcl/h/compbas2.h
>>>>>>> index 20a2b5c..cc7d87c 100755
>>>>>>> --- a/gcl/h/compbas2.h
>>>>>>> +++ b/gcl/h/compbas2.h
>>>>>>> @@ -10,7 +10,6 @@ EXTER int Rset;
>>>>>>>
>>>>>>>  #ifndef U8_DEFINED
>>>>>>>
>>>>>>> -#include <stdint.h>
>>>>>>>
>>>>>>>  typedef int8_t  i8 ;
>>>>>>>  typedef int16_t i16;
>>>>>>
>>>>>> This is a step toward securing a fricas build, which on my box at least
>>>>>> is just about done.  signal.h, from bsdsignal.c, conflicts with my full
>>>>>> stdint on some symbol containing 'fds', which I do not need.   The
>>>>>> intent is to extract the needed parts in h/mstdint.h.  This is an
>>>>>> intermediate file removed by make, but you can look at it with 'make
>>>>>> h/mstdint.h' from the top level.  Apparently the regexp used there needs
>>>>>> adjusting for your system.
>>>>>>
>>>>>>> Also note that I had to use GCC 13 instead of clang, because with clang
>>>>>>> even the GMP building part doesn't success at the linking stage. (My
>>>>>>> previous successful GCL 2.7.0 build was also based on GCC 13.)
>>>>>>>
>>>>>>
>>>>>> Good to hear.  I had trouble with gcc13 on Catalina which I did not
>>>>>> pursue as it would not get me gprof anyway :-(.  I'm using the external
>>>>>> gmp library which works well -- does this not work for you?  I'm
>>>>>> thinking of removing the convenience copy of gmp4.
>>>>>>
>>>>>> Take care,
>>>>>>
>>>>>
>>>>
>>>
>> 
>

-- 
Camm Maguire                                        c...@maguirefamily.org
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

Reply via email to