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

[wasm] AOT app build breaks with InvariantGlobalization=true #48847

Closed
radical opened this issue Feb 26, 2021 · 10 comments · Fixed by #48868 or #49492
Closed

[wasm] AOT app build breaks with InvariantGlobalization=true #48847

radical opened this issue Feb 26, 2021 · 10 comments · Fixed by #48868 or #49492
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Milestone

Comments

@radical
Copy link
Member

radical commented Feb 26, 2021

To reproduce with master:

  1. add <InvariantGlobalization>true</InvariantGlobalization> to src/mono/sample/wasm/console/Wasm.Console.Sample.csproj,
  2. build make clean build AOT=1

This fails with:

Task "RunWithEmSdkEnv" (TaskId:119)
Task Parameter:Command=emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8
Task Parameter:EmSdkPath=/Users/radical/dev/r3/src/mono/wasm/emsdk (TaskId:119)
Using Command: bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['c
bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_crea

error: undefined symbol: u_errorName (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols (TaskId:119)
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0` (TaskId:119)
warning: _u_errorName may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
error: undefined symbol: udata_setCommonData (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: _udata_setCommonData may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
Error: Aborting compilation due to previous errors (TaskId:119)

emcc: error: '/Users/radical/dev/r3/src/mono/wasm/emsdk/node/12.18.1_64bit/bin/node /Users/radical/dev/r3/src/mono/wasm/emsdk/upstream/emscripten/src/compiler.js /var/folders/7c/zpmy8k_d4d1grky_s154kk640000gp/T/tmpmw4p7957.txt' failed (1) (TaskId:119

This seems to be caused by 3473d30d76a

Make sure pal_icushim_static.c is linked in even if no symbols are us…
…ed from it, so the EMSCRIPTEN_KEEPALIVE functions in it are actually kept.

It works before this commit, and breaks with it.

/cc @vargaz @lewing

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 26, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@radical radical added the arch-wasm WebAssembly architecture label Feb 26, 2021
@ghost
Copy link

ghost commented Feb 26, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

To reproduce with master:

  1. add <InvariantGlobalization>true</InvariantGlobalization> to src/mono/sample/wasm/console/Wasm.Console.Sample.csproj,
  2. build make clean build AOT=1

This fails with:

Task "RunWithEmSdkEnv" (TaskId:119)
Task Parameter:Command=emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8
Task Parameter:EmSdkPath=/Users/radical/dev/r3/src/mono/wasm/emsdk (TaskId:119)
Using Command: bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['c
bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_crea

error: undefined symbol: u_errorName (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols (TaskId:119)
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0` (TaskId:119)
warning: _u_errorName may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
error: undefined symbol: udata_setCommonData (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: _udata_setCommonData may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
Error: Aborting compilation due to previous errors (TaskId:119)

emcc: error: '/Users/radical/dev/r3/src/mono/wasm/emsdk/node/12.18.1_64bit/bin/node /Users/radical/dev/r3/src/mono/wasm/emsdk/upstream/emscripten/src/compiler.js /var/folders/7c/zpmy8k_d4d1grky_s154kk640000gp/T/tmpmw4p7957.txt' failed (1) (TaskId:119

This seems to be caused by 3473d30d76a

Make sure pal_icushim_static.c is linked in even if no symbols are us…
…ed from it, so the EMSCRIPTEN_KEEPALIVE functions in it are actually kept.

It works before this commit, and breaks with it.

/cc @vargaz @lewing

Author: radical
Assignees: -
Labels:

arch-wasm, untriaged

Milestone: -

vargaz added a commit to vargaz/runtime that referenced this issue Feb 27, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 27, 2021
@radical radical removed the untriaged New issue has not been triaged by the area owner label Feb 27, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 27, 2021
@steveisok
Copy link
Member

If I run the Invariant tests locally with EnableAggressiveTrimming=true and RunAOTCompilation=true, I hit:

 error: undefined symbol: u_errorName (referenced by top-level compiled C/C++ code)
  warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
  warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
  warning: _u_errorName may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
  error: undefined symbol: u_getVersion (referenced by top-level compiled C/C++ code)
  warning: _u_getVersion may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
  error: undefined symbol: udata_setCommonData (referenced by top-level compiled C/C++ code)
  warning: _udata_setCommonData may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library

@steveisok steveisok reopened this Mar 6, 2021
@marek-safar marek-safar added this to the 6.0.0 milestone Mar 6, 2021
@vargaz
Copy link
Contributor

vargaz commented Mar 6, 2021

This is because src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs calls
Interop.GetICUVersion () which causes references to icu functions.

@ghost
Copy link

ghost commented Mar 6, 2021

Tagging subscribers to this area: @CoffeeFlux
See info in area-owners.md if you want to be subscribed.

Issue Details

To reproduce with master:

  1. add <InvariantGlobalization>true</InvariantGlobalization> to src/mono/sample/wasm/console/Wasm.Console.Sample.csproj,
  2. build make clean build AOT=1

This fails with:

Task "RunWithEmSdkEnv" (TaskId:119)
Task Parameter:Command=emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8
Task Parameter:EmSdkPath=/Users/radical/dev/r3/src/mono/wasm/emsdk (TaskId:119)
Using Command: bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['c
bash -c 'source /Users/radical/dev/r3/src/mono/wasm/emsdk/emsdk_env.sh > /dev/null 2>&1 && emcc --profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s USE_ZLIB=1  -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_crea

error: undefined symbol: u_errorName (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols (TaskId:119)
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0` (TaskId:119)
warning: _u_errorName may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
error: undefined symbol: udata_setCommonData (referenced by top-level compiled C/C++ code) (TaskId:119)
warning: _udata_setCommonData may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library (TaskId:119)
Error: Aborting compilation due to previous errors (TaskId:119)

emcc: error: '/Users/radical/dev/r3/src/mono/wasm/emsdk/node/12.18.1_64bit/bin/node /Users/radical/dev/r3/src/mono/wasm/emsdk/upstream/emscripten/src/compiler.js /var/folders/7c/zpmy8k_d4d1grky_s154kk640000gp/T/tmpmw4p7957.txt' failed (1) (TaskId:119

This seems to be caused by 3473d30d76a

Make sure pal_icushim_static.c is linked in even if no symbols are us…
…ed from it, so the EMSCRIPTEN_KEEPALIVE functions in it are actually kept.

It works before this commit, and breaks with it.

/cc @vargaz @lewing

Author: radical
Assignees: vargaz
Labels:

arch-wasm, area-VM-meta-mono

Milestone: 6.0.0

@steveisok
Copy link
Member

This is because src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs calls

Interop.GetICUVersion () which causes references to icu functions.

Yup, that appears to be it. If I removed that method the tests pass.

@lewing
Copy link
Member

lewing commented Mar 8, 2021

Sound like aggressive trimming isn't preserving PlatformDetection members correctly when they are only accessed from the attribute? That might explain several problems.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 11, 2021
@lewing
Copy link
Member

lewing commented Mar 11, 2021

This isn't related to PlatformDetection, @radical was able to reproduce it in the console sample with native linking turned on.

@steveisok
Copy link
Member

Interesting. For the invariant tests, I was able to pass if I completely removed the reflection from GetICUVersion

steveisok pushed a commit that referenced this issue Mar 11, 2021
Disable the conditional inclusion to fix #48847 until we have a solution.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 11, 2021
@lewing
Copy link
Member

lewing commented Mar 11, 2021

Interesting. For the invariant tests, I was able to pass if I completely removed the reflection from GetICUVersion

This is exactly why #49492 is needed, it isn't safe to completely condition on InvariantMode. Assuming that the platform check was properly retained, pinvoke-table.h would root GlobalizationNative_GetICUVersion and everything would function properly. Without #49492 you end up with missing symbols.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Projects
None yet
6 participants