-
Notifications
You must be signed in to change notification settings - Fork 5k
[wasm] Build improvements based on feedback #59391
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tagging subscribers to 'arch-wasm': @lewing Issue Detailsnull
|
28130de
to
c85b5ca
Compare
8f566c3
to
0da5608
Compare
lewing
reviewed
Sep 22, 2021
radical
commented
Sep 22, 2021
The task needs to run `mono-aot-cross` on all the assemblies, even if a given assembly is older than its output files, so as to correctly handle changes in its dependencies. This commit tries to check if all the input assemblies are up-to-date with their corresponding output files, and avoids doing any work if that's true.
`WasmNativeStrip` -> `false` Compile, and link optimization flags for `emcc` to `-O1`
.. rebuilds. Specifically, when a rebuild causes only the *linking* part to be run again. In that case, we were correctly skipping over compiling native files, but didn't add them to `@(FileWrites)`, which caused msbuild's incremental clean logic to treat them as "orphaned" files, and delete them!
Co-authored-by: Larry Ewing <lewing@microsoft.com>
- Ensure that the cache gets written even when some of the files failed to compile - And when some were skipped, and others failed
For non-publish builds, undefined symbols will show up as warnings: ``` EXEC : warning : undefined symbol: sqlite3_column_database_name (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_column_origin_name (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_column_table_name (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_snapshot_cmp (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_snapshot_free (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_snapshot_get (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_snapshot_open (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] EXEC : warning : undefined symbol: sqlite3_snapshot_recover (referenced by top-level compiled C/C++ code) [/BlazorWebAssemblySqlite.csproj] ```
Currently, for a variadic function like: `int sqlite3_config(int, ...);` .. and multiple pinvokes like: ```csharp [DllImport(SQLITE_DLL, ExactSpelling=true, EntryPoint = "sqlite3_config", CallingConvention = CALLING_CONVENTION)] public static extern unsafe int sqlite3_config_none(int op); [DllImport(SQLITE_DLL, ExactSpelling=true, EntryPoint = "sqlite3_config", CallingConvention = CALLING_CONVENTION)] public static extern unsafe int sqlite3_config_int(int op, int val); [DllImport(SQLITE_DLL, ExactSpelling=true, EntryPoint = "sqlite3_config", CallingConvention = CALLING_CONVENTION)] public static extern unsafe int sqlite3_config_log(int op, NativeMethods.callback_log func, hook_handle pvUser); ``` .. we generate: ```c int sqlite3_config (int); int sqlite3_config (int,int); int sqlite3_config (int,int,int); ``` .. which fails to compile. Instead, this patch will generate a variadic declaration with one fixed parameter: ```c // Variadic signature created for // System.Int32 sqlite3_config_none(System.Int32) // System.Int32 sqlite3_config_int(System.Int32, System.Int32) // System.Int32 sqlite3_config_log(System.Int32, SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods+callback_log, SQLitePCL.hook_handle) int sqlite3_config (int, ...); ``` TODO: functions with different first argument
- For pinvokes with function pointers, *no* declaration is added to `pinvoke-table.h`, and a warning is raised: ``` warning : DllImports with function pointers are not supported. Calling them will fail. Managed DllImports: [/Users/radical/dev/r2/artifacts/bin/Wasm.Build.Tests/net6.0-Release/browser-wasm/g3acrk4b.a0o/variadic_g3acrk4b.a0o.csproj] warning : Type: Test, Method: System.Int32 using_sum_one(?) [/Users/radical/dev/r2/artifacts/bin/Wasm.Build.Tests/net6.0-Release/browser-wasm/g3acrk4b.a0o/variadic_g3acrk4b.a0o.csproj] ``` - Also, handle multiple pinvokes with the same number of params, but different types
- pinvokes with function pointers could be for variadic functions too - if there are multiple pinvokes for the same native function, but some of them have function pointers, then ignore those but generate the declaration for the rest - raise better warnings - and emit info about the variadic pinvokes in pinvoke-table.h
…p-to-date" check" Newer timestamp, but unchanged file is an indication of a build issue, and doesn't need to be handled in this task. This reverts commit 712dbb3.
Based on feedback from Zoltan
steveisok
approved these changes
Sep 28, 2021
wasm test failure is #48717 |
Coreclr failures are #10680 , unrelated to this PR. |
Android failure is #59779 . |
lewing
approved these changes
Sep 30, 2021
/backport release/6.0 |
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1289670399 |
This was referenced Sep 30, 2021
Closed
radical
added a commit
to radical/runtime
that referenced
this pull request
Oct 2, 2021
- Fix for a incremental build issue - Change native build defaults for `Debug` config, to make it faster (thanks @SteveSandersonMS, @mattleibow) - MonoAOTCompiler: - Skip unmanaged assemblies, and emit a warning - PInvokeTableGenerator: - Fix to not fail in presence of native variadic functions, and pinvokes with function pointers (eg. used by sqlite) Co-authored-by: Larry Ewing <lewing@microsoft.com> (cherry picked from commit 80f015d)
steveisok
pushed a commit
that referenced
this pull request
Oct 6, 2021
Backport of #59391 - Fix to handle pinvokes with function pointers, which resolves issue found testing new customer scenario with sqlite - Fixes version of System.Reflection.MetadataLoadContext bundled with WasmBuilderApp task, to use the same as other tasks - Fix for an incremental build issue where the compiled native .o files would incorrectly get deleted after linking. And that would cause them to be recompiled, unnecessarily increasing the build time. - Change the default optimization flag used when building for Debug config from -Oz to -O1 to improve development loop experience.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for a incremental build issue
Change native build defaults for
Debug
config, to make it faster (thanks @SteveSandersonMS, @mattleibow)MonoAOTCompiler:
PInvokeTableGenerator: