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

wasm2c: run tests with -O2 on non-Windows #1939

Merged
merged 13 commits into from
Jul 12, 2022

Conversation

keithw
Copy link
Member

@keithw keithw commented Jun 30, 2022

(This PR is stacked behind #1814, #1877, #1887, and #1930, but if there is interest in landing it sooner, it could be rebased on top of the current ToT.)

Enable optimization when compiling the wasm2c output on non-Windows platforms (effectively GCC and clang). This required:

  • Preventing load instructions from being optimized away if their value is unused (using inline assembly with an input operand and empty code). This is necessary to force an OOB trap on platforms that use mprotect and the signal handler to detect OOB.
  • Disabling tail-call optimization in the compiler, to make sure that infinite recursion traps. (This required bumping the version of macOS in GitHub Actions to get a new-enough AppleClang. We should revert this back to 'macos-latest' as soon as that becomes the default.)
  • Using NaN-quieting versions of a bunch of FP ops that were previously only used on Windows, and adding floor/ceil and promotion/demotion.
  • Using the '-frounding-math' and '-fsignaling-nans' compiler flags to tell GCC and clang not to fold certain FP ops (e.g. subtracting zero, multiplying by 1).

Fixes #1925.

@keithw keithw requested review from kripken, sbc100 and binji June 30, 2022 11:55
@sbc100
Copy link
Member

sbc100 commented Jun 30, 2022

I think it would be great if this and all the other changes in the stack could be rebased to avoid #1814.. then we could land them without being blocked on the instancing discussions.

Could you arrange to have the instancing at the other end of the chain, or do that others somehow depend deeply on it?

@keithw
Copy link
Member Author

keithw commented Jun 30, 2022

#1877 (bulk memory) and #1887 (reference types) unfortunately depend on #1814 in a way that would be a bit annoying to rebase (more details here about why: #1877 (comment)).

The other two would be much easier to rebase (#1930 (exceptions) and #1939 (tests pass with optimization)), and I'm happy to do it if it would help get things moving.

But, instancing is important to us (and I imagine other users) and it would be our hope to actually have that discussion and reach alignment (especially now that we've been building on top of this code for five months in our local fork and have ticked the boxes at #1853 (comment)). How can we help get things moving again there?

@keithw keithw force-pushed the wasm2c-optimize branch from 1deffca to 0246c47 Compare June 30, 2022 13:23
@keithw
Copy link
Member Author

keithw commented Jun 30, 2022

(Rebased on current main branch.)

@sbc100
Copy link
Member

sbc100 commented Jun 30, 2022

#1877 (bulk memory) and #1887 (reference types) unfortunately depend on #1814 in a way that would be a bit annoying to rebase (more details here about why: #1877 (comment)).

The other two would be much easier to rebase (#1930 (exceptions) and #1939 (tests pass with optimization)), and I'm happy to do it if it would help get things moving.

But, instancing is important to us (and I imagine other users) and it would be our hope to actually have that discussion and reach alignment (especially now that we've been building on top of this code for five months in our local fork and have ticked the boxes at #1853 (comment)). How can we help get things moving again there?

My apologies for dragging my feet on that. Perhaps we could have a meeting discuss it next week?

@keithw
Copy link
Member Author

keithw commented Jun 30, 2022

Happy to -- I'll send email, but in general July 6 looks pretty good on our end and we're happy to come up to SF.

keithw added 11 commits July 11, 2022 15:58
Allows compiling with optimization for address-overflow.txt,
skip-stack-guard-page.txt, address.txt, and traps.txt tests.
Allows call and call_indirect tests to pass under
optimization (traps on infinite recursion).

(Bump GitHub macOS version; Xcode 13.2.1 on macOS 11
wasn't honoring the -fno-optimize-sibling-calls flag)
on NaN-quieting versions of trunc/nearbyint/fabs/floor/ceil for
all platforms (not just Windows).

Allows most floating-point tests to run with optimization.
(spec tests don't currently test this)
This gets all tests passing with -O2 on gcc and clang.
@keithw keithw force-pushed the wasm2c-optimize branch from 31436ae to 86a7fa8 Compare July 11, 2022 23:02
Copy link
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

lgtm.. did we decide that we don't need to give folks an opt-out for these these things are don't relate directly to sandbox security? (but are there for spec compliance).

I think I'm OK wither way..

@keithw
Copy link
Member Author

keithw commented Jul 11, 2022

I think that was our tentative conclusion, but we're okay either way too. I guess my mild preference is to wait until somebody wants it and avoid the added complexity if we can, but no strong preference.

(Are you able to change the repo configuration to accept a "macos-12" status check instead of "macos-latest"? GitHub has suggested they will update "macos-latest" by August so hopefully it's temporary...)

@sbc100
Copy link
Member

sbc100 commented Jul 11, 2022

I think that was our tentative conclusion, but we're okay either way too. I guess my mild preference is to wait until somebody wants it and avoid the added complexity if we can, but no strong preference.

(Are you able to change the repo configuration to accept a "macos-12" status check instead of "macos-latest"? GitHub has suggested they will update "macos-latest" by August so hopefully it's temporary...)

Do I have to do something to enable that? I thought it was all driven by the yaml file?

@keithw
Copy link
Member Author

keithw commented Jul 11, 2022

Do I have to do something to enable that? I thought it was all driven by the yaml file?

I think the list of "required" status checks is only in the GitHub "Settings" > "Branches" > Branch Protection Rules for main > "Edit" > Status Checks that Are Required. I think it needs to have "build (macos-12)" added and remove "build (macos-latest)" before this can be merged afaik, at least without an override.

@sbc100 sbc100 merged commit a7d484e into WebAssembly:main Jul 12, 2022
@keithw keithw deleted the wasm2c-optimize branch July 12, 2022 00:13
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.

Several spec tests fail if wasm2c output compiled with -O or -O2
2 participants