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

Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL #13890

Merged
merged 2 commits into from
Mar 27, 2022

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Mar 25, 2022

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.


The CirrusCI jobs need to use LDC until a working dmd release is available

@dlang-bot
Copy link
Contributor

dlang-bot commented Mar 25, 2022

Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
22942 blocker Invalid section type / offset for newer XCode versions

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#13890"

@MoonlightSentinel MoonlightSentinel changed the title cirrus.yml: Use dmd 2.098.1 instead of 2.099.0 [Ignore] Debug failures for OSX on Cirrus Mar 25, 2022
@MoonlightSentinel
Copy link
Contributor Author

Seems to be an issue introduced by newer MacOS 12?

@MoonlightSentinel MoonlightSentinel deleted the ci/mac-linker-error branch March 25, 2022 18:01
@MoonlightSentinel MoonlightSentinel restored the ci/mac-linker-error branch March 26, 2022 13:35
@MoonlightSentinel MoonlightSentinel force-pushed the ci/mac-linker-error branch 2 times, most recently from 2447a5f to 23f1420 Compare March 26, 2022 14:30
// fflush(stdout);

const flags = (I64 ? SecHdrTab64[idx].flags : SecHdrTab[idx].flags);
if (flags == S_ZEROFILL || flags == S_THREAD_LOCAL_ZEROFILL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the error message imply the check should be if(!(flags == S_ZEROFILL...))?

Copy link
Contributor Author

@MoonlightSentinel MoonlightSentinel Mar 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so. The if deals with zero-initialised sections whose size only stored in SDoffset.
FYI the section referenced in the error message is marked as S_THREAD_LOCAL_ZEROFILL

@MoonlightSentinel MoonlightSentinel changed the base branch from master to stable March 26, 2022 16:41
@MoonlightSentinel MoonlightSentinel changed the title [Ignore] Debug failures for OSX on Cirrus Fix 22942 - Check for S_TRHEAD_LOCAL_ZEROFILL alongside S_ZEROFILL Mar 26, 2022
@MoonlightSentinel MoonlightSentinel added Review:Blocking Other Work review and pulling should be a priority Compiler:Backend glue code, optimizer, code generation and removed Severity:Enhancement Severity:Bug Fix labels Mar 26, 2022
@MoonlightSentinel MoonlightSentinel marked this pull request as ready for review March 26, 2022 18:22
@MoonlightSentinel MoonlightSentinel force-pushed the ci/mac-linker-error branch 2 times, most recently from 1740564 to b505033 Compare March 26, 2022 19:10
.cirrus.yml Outdated
@@ -93,6 +93,8 @@ macos12_task:
OS: osx
# 12 CPU cores and 24 GB of memory are available
N: 12
# Temporarily use LDC until a release with a fix for issue 22942 is available (probably 2.101)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding FIXME: to avoid potentially forgetting about this indefinitely and change the name of the tasks, otherwise, people think it's being compiled on DMD.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the FIXME:. Initially renamed the job but Github still waited for the old job - even though the new job was run successfully. So I would rather keep it for now to unblock the CI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the FIXME:. Initially renamed the job but Github still waited for the old job - even though the new job was run successfully. So I would rather keep it for now to unblock the CI.

This is because Github has required on that CI job for that branch in their rules. You need to go to Settings, somewhere in Protected Branches and deselect that job from being required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have permissions, so I can't do it, but probably @RazvanN7 or someone else can do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right. Hardly worth the effort though given that these changes will need to be reverted soon (TM)

DMD releases cannot compile for XCode >= 13.3 because of issue 22942.
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.
@thewilsonator
Copy link
Contributor

Lets get this in to unblock the pipelines.

@thewilsonator
Copy link
Contributor

Also this will need to be cherrypicked to master as well to unblock it, too.

@MoonlightSentinel
Copy link
Contributor Author

I'll open a PR to merge master into stable

@dkorpel
Copy link
Contributor

dkorpel commented Mar 28, 2022

Thank you for tracking this down! This looks really hairy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler:Backend glue code, optimizer, code generation Merge:auto-merge Review:Blocking Other Work review and pulling should be a priority Severity:Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants