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

Build failures with new macOS/Xcode versions #452

Open
varungandhi-src opened this issue Jan 8, 2024 · 2 comments
Open

Build failures with new macOS/Xcode versions #452

varungandhi-src opened this issue Jan 8, 2024 · 2 comments
Assignees
Labels

Comments

@varungandhi-src
Copy link
Contributor

varungandhi-src commented Jan 8, 2024

❯ clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

scip-clang commit: 3035e46

The binaries that are build require rpath to be set:

❯ otool -L /private/var/tmp/_bazel_varun/556335f3782e99575c0c742955be4ea7/execroot/scip_clang/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project/clang/clang-tblgen
/private/var/tmp/_bazel_varun/556335f3782e99575c0c742955be4ea7/execroot/scip_clang/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project/clang/clang-tblgen:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
        /usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 1600.157.0)
        @rpath/libunwind.1.dylib (compatibility version 1.0.0, current version 1.0.0)

But there is no LC_RPATH command in the output of otool -l

/private/var/tmp/_bazel_varun/556335f3782e99575c0c742955be4ea7/execroot/scip_clang/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project/clang/clang-tblgen:
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 792
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x0000000000244000
  fileoff 0
 filesize 2375680
  maxprot 0x00000005
 initprot 0x00000005
   nsects 9
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x000000010000523c
      size 0x00000000001c5aac
    offset 21052
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x00000001001cace8
      size 0x00000000000009fc
    offset 1879272
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 12 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x00000001001cb6e4
      size 0x000000000000099c
    offset 1881828
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __init_offsets
   segname __TEXT
      addr 0x00000001001cc080
      size 0x0000000000000010
    offset 1884288
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000016
 reserved1 0
 reserved2 0
Section
  sectname __gcc_except_tab
   segname __TEXT
      addr 0x00000001001cc090
      size 0x0000000000012268
    offset 1884304
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x00000001001de2f8
      size 0x0000000000016066
    offset 1958648
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x00000001001f4360
      size 0x000000000000a6de
    offset 2048864
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x00000001001fea40
      size 0x000000000000a408
    offset 2091584
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __eh_frame
   segname __TEXT
      addr 0x0000000100208e48
      size 0x000000000003b1b4
    offset 2133576
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x6800000b
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 232
  segname __DATA_CONST
   vmaddr 0x0000000100244000
   vmsize 0x000000000000c000
  fileoff 2375680
 filesize 49152
  maxprot 0x00000003
 initprot 0x00000003
   nsects 2
    flags 0x10
Section
  sectname __got
   segname __DATA_CONST
      addr 0x0000000100244000
      size 0x00000000000002a8
    offset 2375680
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 213 (index into indirect symbol table)
 reserved2 0
Section
  sectname __const
   segname __DATA_CONST
      addr 0x00000001002442a8
      size 0x000000000000ac88
    offset 2376360
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 552
  segname __DATA
   vmaddr 0x0000000100250000
   vmsize 0x0000000000004000
  fileoff 2424832
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 6
    flags 0x0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x0000000100250000
      size 0x0000000000000658
    offset 2424832
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 298 (index into indirect symbol table)
 reserved2 0
Section
  sectname __data
   segname __DATA
      addr 0x0000000100250658
      size 0x0000000000000100
    offset 2426456
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __thread_vars
   segname __DATA
      addr 0x0000000100250758
      size 0x0000000000000060
    offset 2426712
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000013
 reserved1 0
 reserved2 0
Section
  sectname __thread_bss
   segname __DATA
      addr 0x00000001002507b8
      size 0x000000000000001c
    offset 2426808
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000012
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x00000001002507d8
      size 0x0000000000002638
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Section
  sectname __common
   segname __DATA
      addr 0x0000000100252e10
      size 0x00000000000000a9
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 4
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000100254000
   vmsize 0x00000000000c4000
  fileoff 2441216
 filesize 798096
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 5
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 2441216
    rebase_size 1928
       bind_off 2443144
      bind_size 3960
  weak_bind_off 2447104
 weak_bind_size 13208
  lazy_bind_off 2460312
 lazy_bind_size 5824
     export_off 2466136
    export_size 98912
Load command 6
     cmd LC_SYMTAB
 cmdsize 24
  symoff 2572536
   nsyms 8054
  stroff 2703408
 strsize 510656
Load command 7
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 5414
     iextdefsym 5414
     nextdefsym 2372
      iundefsym 7786
      nundefsym 268
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 2701400
  nindirectsyms 501
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 8
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 9
     cmd LC_UUID
 cmdsize 24
    uuid 5AEFC811-54DE-3AC8-8F3E-5E7BBAF982C6
Load command 10
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 14.0
      sdk 14.0
   ntools 1
     tool 3
  version 1022.1
Load command 11
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 12
       cmd LC_MAIN
   cmdsize 24
  entryoff 873392
 stacksize 0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1336.61.1
compatibility version 1.0.0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1600.157.0
compatibility version 1.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libc++abi.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1600.157.0
compatibility version 1.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name @rpath/libunwind.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 08:00:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 17
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 2565048
 datasize 7488
Load command 18
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 2572536
 datasize 0
Load command 19
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 3214064
 datasize 25248

Consequently, there is a failure when attempting to run the binaries (here is an example)

ERROR: /private/var/tmp/_bazel_varun/556335f3782e99575c0c742955be4ea7/external/llvm-project/llvm/BUILD.bazel:724:11: Generating code from table: include/llvm/IR/Intrinsics.td @llvm-project//llvm:intrinsic_RISCV_gen__gen_intrinsic_enums__intrinsic_prefix_riscv_genrule failed: (Aborted): bash failed: error executing command (from target @llvm-project//llvm:intrinsic_RISCV_gen__gen_intrinsic_enums__intrinsic_prefix_riscv_genrule) /bin/bash -c ... (remaining 1 argument skipped)
dyld[14979]: Library not loaded: @rpath/libunwind.1.dylib
  Referenced from: <0A452CEC-C892-3712-8A76-60D49AC12E0B> /private/var/tmp/_bazel_varun/556335f3782e99575c0c742955be4ea7/execroot/scip_clang/bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/llvm-project/llvm/llvm-tblgen
  Reason: no LC_RPATH's found

I cannot quite tell what changed from before -- is libunwind missing from some system directory, is it not getting built for some reason, was LC_RPATH set before but it isn't being set now...

@varungandhi-src varungandhi-src added the bug Something isn't working label Jan 8, 2024
@varungandhi-src varungandhi-src self-assigned this Jan 8, 2024
@varungandhi-src
Copy link
Contributor Author

It looks like libunwind is present in the toolchain.

❯ file bazel-scip-clang/external/llvm_toolchain_llvm/lib/libunwind.1.dylib
bazel-scip-clang/external/llvm_toolchain_llvm/lib/libunwind.1.dylib: Mach-O 64-bit dynamically linked shared library arm64

@varungandhi-src
Copy link
Contributor Author

varungandhi-src commented Mar 1, 2024

It looks like #461 should fix this to some extent (the CI build pipeline works for macOS - https://github.com/sourcegraph/scip-clang/actions/runs/8106024167), still need to figure out my local build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant