Skip to content

Explicitly set bulk memory and nontrapping-fptoint clang flags #22751

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

Merged
merged 10 commits into from
Oct 25, 2024

Conversation

dschuff
Copy link
Member

@dschuff dschuff commented Oct 16, 2024

When clang starts enabling features by default that Emscripten's minimum browser versions want disabled, Emscripten will need to explicitly disable them. This PR does that; once clang rolls, we can update the default versions and tests in a single commit if needed.

See also llvm/llvm-project#112049

@dschuff
Copy link
Member Author

dschuff commented Oct 16, 2024

Also /cc @walkingeyerobot since once it's finished this change will probably need to be mirrored for the bare-clang/non-emcc.py scenario.

@dschuff dschuff changed the title Explicitly set bulk memory clang flag Explicitly set bulk memory and nontrapping-fptoint clang flags Oct 16, 2024
@dschuff dschuff marked this pull request as ready for review October 16, 2024 23:44
@dschuff
Copy link
Member Author

dschuff commented Oct 16, 2024

OK, assuming the tests are good, I think this should work to keep the feature set stable even as LLVM updates the defaults. Once we get the lowering passes in, and ensure our tests are correct, we can back this part out.

sbc100 added a commit to sbc100/emscripten that referenced this pull request Oct 17, 2024
sbc100 added a commit that referenced this pull request Oct 17, 2024
I noticed these were a little out-of-place in #22751
features = {}
feature_count = self.read_byte()
while self.tell() < section.offset + section.size:
prefix = TargetFeaturePrefix(self.read_byte())
Copy link
Member

Choose a reason for hiding this comment

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

What does an argument to TargetFeaturePrefix do here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It just constructs the enum with that value.

class TargetFeaturePrefix(IntEnum):
USED = 0x2b
DISALLOWED = 0x2d
REQUIRED = 0x3d
Copy link
Member

Choose a reason for hiding this comment

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

Do we still emit REQUIRED? I can't find anywhere in LLVM we emit it after llvm/llvm-project@3f34e1b. cc @tlively

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. Seems OK to include it in this enum though. For now we really only check for USED in the test.

Copy link
Member

Choose a reason for hiding this comment

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

This whole system is slightly overengineered (my fault 🫣), and I'm not aware of any uses of REQUIRED. It would be a nice cleanup to remove it entirely here and in the tool conventions doc.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Amazing, thank you!

verify_features_sec_linked('nontrapping-fptoint', False)

compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory', '-sWASM_BIGINT'])
# FIXME? -mno-bulk-memory at link time does not override MIN_SAFARI_VERSION. it probably should?
Copy link
Member Author

@dschuff dschuff Oct 24, 2024

Choose a reason for hiding this comment

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

one weirdness we have currently is that the -m flags (including -mno-signext currently) do not work at link time to disable features (and e.g. do not trigger the lowering passes). Only the the feature_matrix/browser version code does this. So there's currently no way to specify the feature behavior at link time on a granular level. I'm not sure what exactly the use case for this would be, but it wouldn't surprise me too much if there were one. Maybe we should think about that. (although it doesn't need to be this PR).

@dschuff dschuff enabled auto-merge (squash) October 25, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants