D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22942 - Invalid section type / offset for newer XCode versions
Summary: Invalid section type / offset for newer XCode versions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Mac OS X
: P1 blocker
Assignee: No Owner
URL:
Keywords: backend, link-failure, pull
: 22890 (view as issue list)
Depends on:
Blocks:
 
Reported: 2022-03-26 16:39 UTC by moonlightsentinel
Modified: 2022-03-27 02:24 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2022-03-26 16:39:11 UTC
Linking programs on MacOS using newer XCode versions (>= 13.3) fails with an error like this:

ld: section __DATA/__thread_bss has type zero-fill but non-zero file offset file '../generated/build.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Taken from https://cirrus-ci.com/task/5812771504783360?logs=build#L43
Comment 1 Dlang Bot 2022-03-26 16:41:44 UTC
@MoonlightSentinel updated dlang/dmd pull request #13890 "[Ignore] Debug failures for OSX on Cirrus" fixing this issue:

- CirrusCI: Use ldc instead of dmd for MacOs >= 12
  
  DMD releases cannot compile for XCode >= 13.3 because of issue 22942.

- Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL
  
  The code generated an unexpected / invalid header for the `thread_bss`
  section marked as `S_TRHEAD_LOCAL_ZEROFILL`. The generated object file
  is rejected by ld included in newer XCode versions (>= 13.3).
  
  E.g.
  ```
  ld: section __DATA/__thread_bss has type zero-fill but non-zero file
      offset file '../generated/build.o' for architecture x86_64
  ```
  
  This patch changes the existing code to treat `S_TRHEAD_LOCAL_ZEROFILL`
  like `S_ZEROFILL` w.r.t. the section size.

https://github.com/dlang/dmd/pull/13890
Comment 2 Paolo Invernizzi 2022-03-26 18:08:10 UTC
*** Issue 22890 has been marked as a duplicate of this issue. ***
Comment 3 Dlang Bot 2022-03-27 00:47:44 UTC
dlang/dmd pull request #13890 "Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL" was merged into stable:

- dc63f521db4158e28f58323437ba61bb91078087 by MoonlightSentinel:
  CirrusCI: Temporarily use ldc instead of dmd for MacOs >= 12
  
  DMD releases cannot compile for XCode >= 13.3 because of issue 22942.

- 08ff0600f4ddbc0cf285ee9e5633656183766f20 by MoonlightSentinel:
  Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL
  
  The code generated an unexpected / invalid header for the `thread_bss`
  section marked as `S_TRHEAD_LOCAL_ZEROFILL`. The generated object file
  is rejected by ld included in newer XCode versions (>= 13.3).
  
  E.g.
  ```
  ld: section __DATA/__thread_bss has type zero-fill but non-zero file
      offset file '../generated/build.o' for architecture x86_64
  ```
  
  This patch changes the existing code to treat `S_TRHEAD_LOCAL_ZEROFILL`
  like `S_ZEROFILL` w.r.t. the section size.

https://github.com/dlang/dmd/pull/13890
Comment 4 Dlang Bot 2022-03-27 02:24:36 UTC
dlang/dmd pull request #13892 "Merge stable into master" was merged into master:

- 25b8666e690d6b50c59937040ae0f201ae3ef9d9 by MoonlightSentinel:
  CirrusCI: Temporarily use ldc instead of dmd for MacOs >= 12
  
  DMD releases cannot compile for XCode >= 13.3 because of issue 22942.

- d06857e5cf430a566b78264a1635149ce864ed88 by MoonlightSentinel:
  Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL
  
  The code generated an unexpected / invalid header for the `thread_bss`
  section marked as `S_TRHEAD_LOCAL_ZEROFILL`. The generated object file
  is rejected by ld included in newer XCode versions (>= 13.3).
  
  E.g.
  ```
  ld: section __DATA/__thread_bss has type zero-fill but non-zero file
      offset file '../generated/build.o' for architecture x86_64
  ```
  
  This patch changes the existing code to treat `S_TRHEAD_LOCAL_ZEROFILL`
  like `S_ZEROFILL` w.r.t. the section size.

https://github.com/dlang/dmd/pull/13892