On Tuesday, March 14, 2023, 02:53:19 PM GMT+2, Herman ten Brugge via 
Tinycc-devel <tinycc-devel@nongnu.org> wrote:

> I can only test things on macos 12.6 (aarch64) and macos 10.15.7 (x86_64).
> These 2 platforms work with head.
>
> I applied a lot of fixes since november so head is probably the best version.
>
>
> I do not understand why adding debug support fails for osx.
>
> The load command 0x80000034 is LC_DYLD_CHAINED_FIXUPS.
>
> This probably means that you have to configure with option
> '--config-new_macho=no'. If this stil fails can you sent me
> 'otool -l <exe>' of the failing executable and tcc.
>
> Herman


Thanks for the reply.

If indeed it should be invoked with --config-new_macho=no, would it
be possible to auto-detect it? (while still allowing override)

With commit 62096265, '--config-new_macho=no' does not seem to make
a difference, and "hello-exe" still fails the same, starting with:

------------ hello-exe ------------
dyld: REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 4 which is not a 
writable segment (__LINKEDIT) in /Users/avih/dev/tcc/tcc.upstream/tests/./hello
/bin/sh: line 1: 58643 Abort trap: 6 ./hello


With current mob (4dc4e93), '--config-new_macho=no' does make
a difference, where now "hello-exe", "hello-run", and "libtest" do
pass, and "libtest_mt" passes some tests and then fails:

------------ libtest_mt ------------
running fib with mixed calls
 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946
 (28 ms)
running fib in threads
 1 5 8 13 21 34 2 55 89 144 233 3 377 610 987 1597 2584 4181 6765 10946
 (23 ms)
running tcc.c in threads to run fib
 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946
 (4159 ms)
compiling tcc.c 10 times
 1 2 3 4 5 6 7 8 9 10
 (1608 ms)
tcctest.c:3878:15: error: use of unknown builtin '__builtin_clrsb' 
[-Wimplicit-function-declaration]
 cnt[9] += __builtin_clrsb(x);
 ^
tcctest.c:3879:16: error: use of unknown builtin '__builtin_clrsbl' 
[-Wimplicit-function-declaration]
 cnt[10] += __builtin_clrsbl(x);
 ^
tcctest.c:3879:16: note: did you mean '__builtin_clrsb'?
tcctest.c:3878:15: note: '__builtin_clrsb' declared here
 cnt[9] += __builtin_clrsb(x);
 ^
tcctest.c:3880:16: error: use of unknown builtin '__builtin_clrsbll' 
[-Wimplicit-function-declaration]
 cnt[11] += __builtin_clrsbll(x);
 ^
tcctest.c:3880:16: note: did you mean '__builtin_clrsbl'?
tcctest.c:3879:16: note: '__builtin_clrsbl' declared here
 cnt[10] += __builtin_clrsbl(x);
 ^
3 errors generated.
make[2]: *** [test.ref] Error 1
make[1]: *** [all] Error 2
make: *** [test] Error 2


While this does not seem like a load issue anymore, I'm still
attaching the full output of configure && make && make test,
as well as of 'otool -l ./tcc' with current mob (4dc4e93).

- avih
Binary directory    /usr/local/bin
TinyCC directory    /usr/local/lib/tcc
Library directory   /usr/local/lib
Include directory   /usr/local/include
Manual directory    /usr/local/share/man
Info directory      /usr/local/share/info
Doc directory       /usr/local/share/doc
/usr/include dir    
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include
Source path         /Users/avih/dev/tcc/tcc.upstream
C compiler          clang (10.0)
Target OS           Darwin
CPU                 x86_64
Config              OSX new_macho=no
Creating config.mak and config.h
clang -o tcc.o -c tcc.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -DTCC_GITHASH="\"HEAD:4dc4e93 2023-03-13T17:01:35+01:00\""  
-Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o libtcc.o -c libtcc.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -DC2STR conftest.c -o c2str.exe && ./c2str.exe include/tccdefs.h 
tccdefs_.h
clang -o tccpp.o -c tccpp.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccgen.o -c tccgen.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccdbg.o -c tccdbg.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccelf.o -c tccelf.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccasm.o -c tccasm.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccrun.o -c tccrun.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o x86_64-gen.o -c x86_64-gen.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o x86_64-link.o -c x86_64-link.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o i386-asm.o -c i386-asm.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
clang -o tccmacho.o -c tccmacho.c 
-DCONFIG_USR_INCLUDE="\"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include\""
 -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO -DCONFIG_NEW_MACHO=0        
-DONE_SOURCE=0 -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing 
-fheinous-gnu-extensions -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result 
-Wno-string-plus-int -I. 
ar rcs libtcc.a libtcc.o tccpp.o tccgen.o tccdbg.o tccelf.o tccasm.o tccrun.o 
x86_64-gen.o x86_64-link.o i386-asm.o tccmacho.o
clang -o tcc tcc.o libtcc.a -lm -lpthread -ldl  -flat_namespace -undefined 
warning 
../tcc -c libtcc1.c -o libtcc1.o -B.. -I..
../tcc -c alloca.S -o alloca.o -B.. -I..
../tcc -c alloca-bt.S -o alloca-bt.o -B.. -I..
../tcc -c stdatomic.c -o stdatomic.o -B.. -I..
../tcc -c atomic.S -o atomic.o -B.. -I..
../tcc -c builtin.c -o builtin.o -B.. -I..
../tcc -c tcov.c -o tcov.o -B.. -I..
../tcc -c va_list.c -o va_list.o -B.. -I..
../tcc -ar rcs ../libtcc1.a libtcc1.o alloca.o alloca-bt.o stdatomic.o atomic.o 
builtin.o tcov.o va_list.o
../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I..
../tcc -c bt-log.c -o ../bt-log.o -B.. -I..
../tcc -c bcheck.c -o ../bcheck.o -B.. -I.. -g 
perl ./texi2pod.pl tcc-doc.texi tcc-doc.pod
pod2man --section=1 --center="Tiny C Compiler" --release="0.9.27" tcc-doc.pod 
>tcc.1 && rm -f tcc-doc.pod
makeinfo --no-split --html --number-sections -o tcc-doc.html tcc-doc.texi
makeinfo tcc-doc.texi || true
------------ hello-exe ------------
Hello World
------------ hello-run ------------
Hello World
------------ libtest ------------
Hello World!
fib(32) = 2178309
add(32, 64) = 96
------------ libtest_mt ------------
running fib with mixed calls
  1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946
 (34 ms)
running fib in threads
  1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946
 (24 ms)
running tcc.c in threads to run fib
  1 10946 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
 (4167 ms)
compiling tcc.c 10 times
  1 2 3 4 5 6 7 8 9 10
 (1566 ms)
tcctest.c:3878:15: error: use of unknown builtin '__builtin_clrsb' 
[-Wimplicit-function-declaration]
    cnt[9] += __builtin_clrsb(x);
              ^
tcctest.c:3879:16: error: use of unknown builtin '__builtin_clrsbl' 
[-Wimplicit-function-declaration]
    cnt[10] += __builtin_clrsbl(x);
               ^
tcctest.c:3879:16: note: did you mean '__builtin_clrsb'?
tcctest.c:3878:15: note: '__builtin_clrsb' declared here
    cnt[9] += __builtin_clrsb(x);
              ^
tcctest.c:3880:16: error: use of unknown builtin '__builtin_clrsbll' 
[-Wimplicit-function-declaration]
    cnt[11] += __builtin_clrsbll(x);
               ^
tcctest.c:3880:16: note: did you mean '__builtin_clrsbl'?
tcctest.c:3879:16: note: '__builtin_clrsbl' declared here
    cnt[10] += __builtin_clrsbl(x);
               ^
3 errors generated.
make[2]: *** [test.ref] Error 1
make[1]: *** [all] Error 2
make: *** [test] Error 2
./tcc:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x80           2    14       1904 0x00200004
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __PAGEZERO
   vmaddr 0x0000000000000000
   vmsize 0x0000000100000000
  fileoff 0
 filesize 0
  maxprot 0x00000000
 initprot 0x00000000
   nsects 0
    flags 0x0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 632
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x0000000000069000
  fileoff 0
 filesize 430080
  maxprot 0x00000007
 initprot 0x00000005
   nsects 7
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000100001230
      size 0x000000000005a45b
    offset 4656
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x000000010005b68c
      size 0x00000000000001c2
    offset 374412
     align 2^1 (2)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 6 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x000000010005b850
      size 0x00000000000002fe
    offset 374864
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x000000010005bb50
      size 0x0000000000004370
    offset 375632
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x000000010005fec0
      size 0x00000000000049d4
    offset 392896
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x0000000100064894
      size 0x00000000000003f4
    offset 411796
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __eh_frame
   segname __TEXT
      addr 0x0000000100064c88
      size 0x0000000000004370
    offset 412808
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 632
  segname __DATA
   vmaddr 0x0000000100069000
   vmsize 0x000000000002a000
  fileoff 430080
 filesize 4096
  maxprot 0x00000007
 initprot 0x00000003
   nsects 7
    flags 0x0
Section
  sectname __program_vars
   segname __DATA
      addr 0x0000000100069000
      size 0x0000000000000028
    offset 430080
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __nl_symbol_ptr
   segname __DATA
      addr 0x0000000100069028
      size 0x0000000000000010
    offset 430120
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 75 (index into indirect symbol table)
 reserved2 0
Section
  sectname __got
   segname __DATA
      addr 0x0000000100069038
      size 0x0000000000000138
    offset 430136
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 77 (index into indirect symbol table)
 reserved2 0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x0000000100069170
      size 0x0000000000000258
    offset 430448
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 116 (index into indirect symbol table)
 reserved2 0
Section
  sectname __const
   segname __DATA
      addr 0x00000001000693d0
      size 0x0000000000000b00
    offset 431056
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __common
   segname __DATA
      addr 0x0000000100069ed0
      size 0x000000000000014c
    offset 0
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x000000010006a020
      size 0x0000000000028ae8
    offset 0
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000100093000
   vmsize 0x0000000000007000
  fileoff 434176
 filesize 25900
  maxprot 0x00000007
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 4
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 434176
    rebase_size 56
       bind_off 434232
      bind_size 88
  weak_bind_off 0
 weak_bind_size 0
  lazy_bind_off 434320
 lazy_bind_size 1264
     export_off 435584
    export_size 5712
Load command 5
     cmd LC_SYMTAB
 cmdsize 24
  symoff 442336
   nsyms 575
  stroff 452300
 strsize 7776
Load command 6
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 180
     iextdefsym 180
     nextdefsym 316
      iundefsym 496
      nundefsym 79
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 451536
  nindirectsyms 191
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 7
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 8
     cmd LC_UUID
 cmdsize 24
    uuid 9D511FF0-2A71-390A-A17A-7F79EBE25D21
Load command 9
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.6
      sdk 10.13
Load command 10
        cmd LC_UNIXTHREAD
    cmdsize 184
     flavor x86_THREAD_STATE64
      count x86_THREAD_STATE64_COUNT
   rax  0x0000000000000000 rbx 0x0000000000000000 rcx  0x0000000000000000
   rdx  0x0000000000000000 rdi 0x0000000000000000 rsi  0x0000000000000000
   rbp  0x0000000000000000 rsp 0x0000000000000000 r8   0x0000000000000000
    r9  0x0000000000000000 r10 0x0000000000000000 r11  0x0000000000000000
   r12  0x0000000000000000 r13 0x0000000000000000 r14  0x0000000000000000
   r15  0x0000000000000000 rip 0x0000000100001230
rflags  0x0000000000000000 cs  0x0000000000000000 fs   0x0000000000000000
    gs  0x0000000000000000
Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 02:00:02 1970
      current version 1252.50.4
compatibility version 1.0.0
Load command 12
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 441296
 datasize 664
Load command 13
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 441960
 datasize 376
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to