Skip to content

Commit fddee67

Browse files
authored
[mono][wasm] Add changes required by emscripten 3.1.4. (#66410)
1 parent 613f8e7 commit fddee67

4 files changed

Lines changed: 49 additions & 44 deletions

File tree

src/mono/mono.proj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@
602602
<MonoUseCrossTool>true</MonoUseCrossTool>
603603
<MonoAotAbi>wasm32-unknown-none</MonoAotAbi>
604604
<MonoAotOffsetsFile>$(MonoObjCrossDir)offsets-wasm32-unknown-none.h</MonoAotOffsetsFile>
605-
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(EMSDK_PATH)/upstream/lib/libclang.dylib</MonoLibClang>
606-
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(EMSDK_PATH)/upstream/lib/libclang.so</MonoLibClang>
607-
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Windows'))">$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'upstream', 'bin', 'libclang.dll'))</MonoLibClang>
605+
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(MonoAOTLLVMDir)/lib/libclang.dylib</MonoLibClang>
606+
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(MonoAOTLLVMDir)/lib/libclang.so</MonoLibClang>
607+
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Windows'))">$([MSBuild]::NormalizePath('$(MonoAOTLLVMDir)', 'bin', 'libclang.dll'))</MonoLibClang>
608608
<PythonCmd Condition="'$(HostOS)' == 'windows'">setlocal EnableDelayedExpansion &amp;&amp; call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; !EMSDK_PYTHON!</PythonCmd>
609609
<_ForceRelease Condition="$([MSBuild]::IsOSPlatform('Windows')) and '$(TargetArchitecture)' == 'wasm' and '$(Configuration)' == 'Debug'">true</_ForceRelease>
610610
</PropertyGroup>

src/mono/sample/wasm/browser-bench/Console/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ endif
99
PROJECT_NAME=Wasm.Console.Bench.Sample.csproj
1010
CONSOLE_DLL=Wasm.Console.Bench.Sample.dll
1111
MAIN_JS=test-main.js
12+
ARGS=--run $(CONSOLE_DLL)
1213

1314
run: run-console

src/mono/wasm/wasm.proj

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -65,43 +65,6 @@
6565
</Target>
6666

6767
<Target Name="GenerateEmccPropsAndRspFiles">
68-
<ItemGroup>
69-
<_EmccLinkFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' == 'true'" />
70-
<_EmccLinkFlags Include="-s ALLOW_MEMORY_GROWTH=1" />
71-
<_EmccLinkFlags Include="-s NO_EXIT_RUNTIME=1" />
72-
<_EmccLinkFlags Include="-s FORCE_FILESYSTEM=1" />
73-
<_EmccLinkFlags Include="-s EXPORTED_RUNTIME_METHODS=&quot;['FS','print','ccall','cwrap','setValue','getValue','UTF8ToString','UTF8ArrayToString','FS_createPath','FS_createDataFile','removeRunDependency','addRunDependency', 'FS_readFile']&quot;" />
74-
<!-- _htons,_ntohs,__get_daylight,__get_timezone,__get_tzname are exported temporarily, until the issue is fixed in emscripten, https://github.com/dotnet/runtime/issues/64724 -->
75-
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=_free,_malloc,_htons,_ntohs,__get_daylight,__get_timezone,__get_tzname,_memalign" />
76-
<_EmccLinkFlags Include="--source-map-base http://example.com" />
77-
<_EmccLinkFlags Include="-s STRICT_JS=1" />
78-
<_EmccLinkFlags Include="-s EXPORT_NAME=&quot;'createDotnetRuntime'&quot;" />
79-
<_EmccLinkFlags Include="-s MODULARIZE=1"/>
80-
<_EmccLinkFlags Include="-Wl,--allow-undefined"/>
81-
<_EmccLinkFlags Include="-s ENVIRONMENT=&quot;web,webview,worker,node,shell&quot;" />
82-
</ItemGroup>
83-
84-
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
85-
<_EmccLinkFlags Include="--profiling-funcs" />
86-
<_EmccFlags Include="@(_EmccCommonFlags)" />
87-
</ItemGroup>
88-
89-
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
90-
<_EmccFlags Include="@(_EmccCommonFlags)" />
91-
</ItemGroup>
92-
93-
<WriteLinesToFile File="$(_EmccDefaultsRspPath)"
94-
Lines="@(_EmccFlags)"
95-
WriteOnlyWhenDifferent="true"
96-
Overwrite="true" />
97-
<WriteLinesToFile File="$(_EmccCompileRspPath)"
98-
Lines="@(_EmccCompileFlags)"
99-
WriteOnlyWhenDifferent="true"
100-
Overwrite="true" />
101-
<WriteLinesToFile File="$(_EmccLinkRspPath)"
102-
Lines="@(_EmccLinkFlags)"
103-
WriteOnlyWhenDifferent="true"
104-
Overwrite="true" />
10568

10669
<!-- Generate emcc-props.json -->
10770

@@ -123,7 +86,12 @@
12386
<_EmccVersionRegexPattern>^ *emcc \([^\)]+\) *([0-9\.]+).*\(([^\)]+)\)$</_EmccVersionRegexPattern>
12487
<_EmccVersion>$([System.Text.RegularExpressions.Regex]::Match($(_EmccVersionRaw), $(_EmccVersionRegexPattern)).Groups[1].Value)</_EmccVersion>
12588
<_EmccVersionHash>$([System.Text.RegularExpressions.Regex]::Match($(_EmccVersionRaw), $(_EmccVersionRegexPattern)).Groups[2].Value)</_EmccVersionHash>
89+
</PropertyGroup>
12690

91+
<Error Text="Failed to parse emcc version, and hash from the full version string: '$(_EmccVersionRaw)'"
92+
Condition="'$(_EmccVersion)' == '' or '$(_EmccVersionHash)' == ''" />
93+
94+
<PropertyGroup>
12795
<_EmccPropsJson>
12896
<![CDATA[
12997
{
@@ -139,13 +107,49 @@
139107
</_EmccPropsJson>
140108
</PropertyGroup>
141109

142-
<Error Text="Failed to parse emcc version, and hash from the full version string: '$(_EmccVersionRaw)'"
143-
Condition="'$(_EmccVersion)' == '' or '$(_EmccVersionHash)' == ''" />
144-
145110
<WriteLinesToFile File="$(NativeBinDir)src\emcc-props.json"
146111
Lines="$(_EmccPropsJson)"
147112
Overwrite="true"
148113
WriteOnlyWhenDifferent="true" />
114+
115+
<ItemGroup>
116+
<_EmccLinkFlags Include="-s EXPORT_ES6=1" Condition="'$(WasmEnableES6)' == 'true'" />
117+
<_EmccLinkFlags Include="-s ALLOW_MEMORY_GROWTH=1" />
118+
<_EmccLinkFlags Include="-s NO_EXIT_RUNTIME=1" />
119+
<_EmccLinkFlags Include="-s FORCE_FILESYSTEM=1" />
120+
<_EmccLinkFlags Include="-s EXPORTED_RUNTIME_METHODS=&quot;['FS','print','ccall','cwrap','setValue','getValue','UTF8ToString','UTF8ArrayToString','FS_createPath','FS_createDataFile','removeRunDependency','addRunDependency', 'FS_readFile']&quot;" />
121+
<!-- _htons,_ntohs,__get_daylight,__get_timezone,__get_tzname are exported temporarily, until the issue is fixed in emscripten, https://github.com/dotnet/runtime/issues/64724 -->
122+
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=_free,_malloc,_memalign,_memset" Condition="$([MSBuild]::VersionGreaterThan('$(_EmccVersion)', '3.0'))" />
123+
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=_free,_malloc,_htons,_ntohs,__get_daylight,__get_timezone,__get_tzname,_memalign" Condition="$([MSBuild]::VersionLessThan('$(_EmccVersion)', '3.0'))" />
124+
<_EmccLinkFlags Include="--source-map-base http://example.com" />
125+
<_EmccLinkFlags Include="-s STRICT_JS=1" />
126+
<_EmccLinkFlags Include="-s EXPORT_NAME=&quot;'createDotnetRuntime'&quot;" />
127+
<_EmccLinkFlags Include="-s MODULARIZE=1"/>
128+
<_EmccLinkFlags Include="-Wl,--allow-undefined"/>
129+
<_EmccLinkFlags Include="-s ENVIRONMENT=&quot;web,webview,worker,node,shell&quot;" />
130+
</ItemGroup>
131+
132+
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
133+
<_EmccLinkFlags Include="--profiling-funcs" />
134+
<_EmccFlags Include="@(_EmccCommonFlags)" />
135+
</ItemGroup>
136+
137+
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
138+
<_EmccFlags Include="@(_EmccCommonFlags)" />
139+
</ItemGroup>
140+
141+
<WriteLinesToFile File="$(_EmccDefaultsRspPath)"
142+
Lines="@(_EmccFlags)"
143+
WriteOnlyWhenDifferent="true"
144+
Overwrite="true" />
145+
<WriteLinesToFile File="$(_EmccCompileRspPath)"
146+
Lines="@(_EmccCompileFlags)"
147+
WriteOnlyWhenDifferent="true"
148+
Overwrite="true" />
149+
<WriteLinesToFile File="$(_EmccLinkRspPath)"
150+
Lines="@(_EmccLinkFlags)"
151+
WriteOnlyWhenDifferent="true"
152+
Overwrite="true" />
149153
</Target>
150154

151155
<!-- This is a documented target that is invoked by developers in their innerloop work. -->

src/native/libs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER)
4343
endif ()
4444

4545
set(CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir})
46-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
46+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wno-declaration-after-statement")
4747

4848
add_compile_options(-I${CMAKE_CURRENT_SOURCE_DIR}/Common)
4949
add_compile_options(-I${CMAKE_CURRENT_BINARY_DIR}/Common)

0 commit comments

Comments
 (0)