Skip to content

Conversation

@dschuff
Copy link
Member

@dschuff dschuff commented Nov 20, 2024

The signext feature is enabled by default by clang and can be overridden
with the -msign-ext/-mno-sign-ext flags at compile time. However it
cannot be individually controlled at link time (it can only be lowered
by setting the min browser version). This PR allows -mno-sign-ext,
-msign-ext (and likewise -mbulk-memory) to be used at link time as well,
and override the browser version control.

The signext feature is enabled by default by clang and can be overridden
with the -msign-ext/-mno-sign-ext flags at compile time. However it
cannot be individually controlled at link time (it can only be lowered
by setting the min browser version). This PR allows -mno-sign-ext
to be used at link time as well, and override the browser version
control.
@dschuff dschuff requested a review from sbc100 November 20, 2024 01:03
@dschuff dschuff requested a review from kripken November 20, 2024 01:23

var BULK_MEMORY = false;

var SIGN_EXT = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we name these internal settings so we can identify them easily. Maybe "F_SIGN_EXT" and "F_BULK_MEMORY"?

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems a little obscure to me still. Is FEATURE_SIGN_EXT too long? the only downside is for things like bulk memory that also impact how things are linked, it's not just a wasm feature. but maybe that's fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These are all internal settings so we are free to change them later and we can bikeshed to our hearts content.

I would go for the short prefix myself, since its an internal thing, but either way is fine with me. Can also be a followup.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually it turns out we don't need this setting, the logic can just stay in feature_matrix. I backed this out for now, can revisit if we need more settings in the upcoming PRs.

settings.SIGN_EXT = 1
feature_matrix.enable_feature(feature_matrix.Feature.SIGN_EXT, '-msign-ext')
elif arg == '-mno-sign-ext':
feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not do the same for bulk memory? I guess because we don't have a link time lowering yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, link time lowering is in my local branch but not upstream yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, perhaps we can generalize this once we do the same for bulk memory, perhaps even make it data driven? e.g.

# map command line feature flags to (setting, feature) pairs 
feature_flags = {
  'bulk-memory': ('BULK_MEMORY', feature_matrix.Feature.SIGN_EXT),
  ...
}

Copy link
Member Author

@dschuff dschuff Nov 20, 2024

Choose a reason for hiding this comment

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

Yeah, I'll come back to the best way to do this this with bulk and nontrapping once they are hooked up to feature_matrix.

@dschuff
Copy link
Member Author

dschuff commented Nov 20, 2024

PTAL, I also fixed explicit enabling/disabling for bulk memory here, since we already had processing for that.

def disable_feature(feature):
"""Allow the user to disable a feature that would otherwise be on by default.
"""
disable_override_features.add(feature)
Copy link
Member

Choose a reason for hiding this comment

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

Can we have the same default override behavior in enable and disable, so they are parallel?

Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior is asymmetric in that there is no implicit disabling, only implicit enabling. So disable_feature can only be an explicit disable and will always override. But enable_feature can be explicit for a feature requested by a user, or implicit for a feature enabled as a result of another feature bumping the min browser versions.

@dschuff dschuff enabled auto-merge (squash) November 20, 2024 22:25
@dschuff
Copy link
Member Author

dschuff commented Nov 20, 2024

Going to land this to avoid conflict with the upcoming PRs but they will be adding onto this, so any more suggestions can be addressed there.

@dschuff dschuff merged commit 1b15088 into emscripten-core:main Nov 20, 2024
28 checks passed
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.

3 participants