Skip to content

Commit 267102d

Browse files
[WASM] Build the time zone data for WASM as part of libs.native (#119288)
1 parent f87bc53 commit 267102d

File tree

16 files changed

+145
-185
lines changed

16 files changed

+145
-185
lines changed

eng/testing/WasmRunnerTemplate.cmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ if /I [%XHARNESS_COMMAND%] == [test] (
4747
)
4848

4949
if [%JS_ENGINE_ARGS%] == [] (
50-
set "JS_ENGINE_ARGS=--engine-arg^=--stack-trace-limit^=1000 --engine-arg^=--module"
50+
set "JS_ENGINE_ARGS=--engine-arg^=--stack-trace-limit^=1000"
51+
52+
if [!JS_ENGINE!] == [--engine^=V8] (
53+
set "JS_ENGINE_ARGS=!JS_ENGINE_ARGS! --engine-arg^=--module"
54+
)
5155
)
5256
) else (
5357
if /I [%SCENARIO%] == [WasmTestOnChrome] (

eng/testing/WasmRunnerTemplate.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ if [[ -z "$XHARNESS_COMMAND" ]]; then
3636
fi
3737

3838
if [[ "$XHARNESS_COMMAND" == "test" ]]; then
39+
if [[ -z "$JS_ENGINE" ]]; then
40+
JS_ENGINE="--engine=V8"
41+
fi
3942
if [[ -z "$MAIN_JS" ]]; then
4043
MAIN_JS="--js-file=test-main.js"
4144
fi
4245

4346
if [[ -z "$JS_ENGINE_ARGS" ]]; then
44-
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000 --engine-arg=--module"
45-
fi
47+
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
4648

47-
if [[ -z "$JS_ENGINE" ]]; then
48-
JS_ENGINE="--engine=V8"
49+
if [[ "$JS_ENGINE" == "--engine=V8" ]] ; then
50+
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--module"
51+
fi
4952
fi
5053
else
5154
if [[ "$SCENARIO" == "WasmTestOnChrome" || "$SCENARIO" == "wasmtestonchrome" ]]; then

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
<PlatformManifestFileEntry Include="libSystem.Native.a" IsNative="true" />
8383
<PlatformManifestFileEntry Include="libSystem.Native.dylib" IsNative="true" />
8484
<PlatformManifestFileEntry Include="libSystem.Native.so" IsNative="true" />
85+
<PlatformManifestFileEntry Include="libSystem.Native.TimeZoneData.a" IsNative="true" />
86+
<PlatformManifestFileEntry Include="libSystem.Native.TimeZoneData.Invariant.a" IsNative="true" />
8587
<PlatformManifestFileEntry Include="libSystem.Net.Http.Native.a" IsNative="true" />
8688
<PlatformManifestFileEntry Include="libSystem.Net.Http.Native.dylib" IsNative="true" />
8789
<PlatformManifestFileEntry Include="libSystem.Net.Http.Native.so" IsNative="true" />
@@ -220,7 +222,6 @@
220222
<PlatformManifestFileEntry Include="libmono-wasm-eh-wasm.a" IsNative="true" />
221223
<PlatformManifestFileEntry Include="libmono-wasm-simd.a" IsNative="true" />
222224
<PlatformManifestFileEntry Include="libmono-wasm-nosimd.a" IsNative="true" />
223-
<PlatformManifestFileEntry Include="wasm-bundled-timezones.a" IsNative="true" />
224225
<PlatformManifestFileEntry Include="dotnet.js" IsNative="true" />
225226
<PlatformManifestFileEntry Include="dotnet.js.map" IsNative="true" />
226227
<PlatformManifestFileEntry Include="dotnet.runtime.js" IsNative="true" />

src/mono/browser/browser.proj

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == '' and '$(WasmEnableThreads)' == 'true'">true</WasmEnableJsInteropByValue>
2929
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == ''">false</WasmEnableJsInteropByValue>
3030
<EnableDiagnostics Condition="'$(EnableDiagnostics)' == ''">false</EnableDiagnostics>
31-
<FilterSystemTimeZones Condition="'$(FilterSystemTimeZones)' == ''">false</FilterSystemTimeZones>
3231
<EmccCmd>emcc</EmccCmd>
3332
<WasmObjDir>$(ArtifactsObjDir)wasm</WasmObjDir>
3433
<_EmccDefaultsRspPath>$(NativeBinDir)src\emcc-default.rsp</_EmccDefaultsRspPath>
@@ -46,7 +45,6 @@
4645

4746
<ItemGroup>
4847
<PackageReference Include="Microsoft.NETCore.Runtime.ICU.Transport" PrivateAssets="all" Version="$(MicrosoftNETCoreRuntimeICUTransportVersion)" GeneratePathProperty="true" />
49-
<PackageReference Include="System.Runtime.TimeZoneData" PrivateAssets="all" Version="$(SystemRuntimeTimeZoneDataVersion)" GeneratePathProperty="true" />
5048
</ItemGroup>
5149

5250
<UsingTask TaskName="ManagedToNativeGenerator" AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
@@ -81,74 +79,7 @@
8179
</ManagedToNativeGenerator>
8280
</Target>
8381

84-
<UsingTask TaskName="EmitBundleSourceFiles" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" TaskFactory="TaskHostFactory" />
85-
<Target Name="GenerateTimezonesArchive" Returns="@(_WasmArchivedTimezones)" Condition="'$(InvariantTimezone)' != 'true'">
86-
<PropertyGroup>
87-
<_WasmTimezonesPath>$([MSBuild]::NormalizePath('$(PkgSystem_Runtime_TimeZoneData)', 'contentFiles', 'any', 'any', 'data'))</_WasmTimezonesPath>
88-
<_WasmTimezonesBundleSourceFile>wasm-bundled-timezones.c</_WasmTimezonesBundleSourceFile>
89-
<_WasmTimezonesBundleArchive>$(WasmObjDir)\wasm-bundled-timezones.a</_WasmTimezonesBundleArchive>
90-
<_WasmTimezonesSourcesRsp>$(WasmObjDir)\wasm-bundled-timezones-sources.rsp</_WasmTimezonesSourcesRsp>
91-
<_WasmTimezonesArchiveRsp>$(WasmObjDir)\wasm-bundled-timezones-archive.rsp</_WasmTimezonesArchiveRsp>
92-
</PropertyGroup>
93-
<ItemGroup>
94-
<_WasmTimezonesInternal Include="$(_WasmTimezonesPath)\**\*.*" WasmRole="Timezone"/>
95-
</ItemGroup>
96-
<ItemGroup>
97-
<_WasmTimezonesInternal Update="@(_WasmTimezonesInternal)">
98-
<RegisteredName>/usr/share/zoneinfo/$([MSBuild]::MakeRelative($(_WasmTimezonesPath), %(_WasmTimezonesInternal.Identity)).Replace('\','/'))</RegisteredName>
99-
</_WasmTimezonesInternal>
100-
</ItemGroup>
101-
<!-- TODO make this incremental compilation -->
102-
<EmitBundleSourceFiles
103-
FilesToBundle="@(_WasmTimezonesInternal)"
104-
BundleRegistrationFunctionName="mono_register_timezones_bundle"
105-
BundleFile="$(_WasmTimezonesBundleSourceFile)"
106-
OutputDirectory="$(WasmObjDir)">
107-
<Output TaskParameter="BundledResources" ItemName="BundledWasmTimezones" />
108-
</EmitBundleSourceFiles>
10982

110-
<ItemGroup>
111-
<_WasmBundleTimezonesSources Include="$([MSBuild]::MakeRelative($(WasmObjDir), %(BundledWasmTimezones.DestinationFile)).Replace('\','/'))" />
112-
<_WasmBundleTimezonesSources Include="$(_WasmTimezonesBundleSourceFile)" />
113-
</ItemGroup>
114-
<WriteLinesToFile File="$(_WasmTimezonesSourcesRsp)"
115-
Overwrite="true"
116-
Lines="@(_WasmBundleTimezonesSources, ' ')"
117-
WriteOnlyWhenDifferent="true" />
118-
<RunWithEmSdkEnv Command="$(EmccCmd) -xc -c @$(_WasmTimezonesSourcesRsp)"
119-
WorkingDirectory="$(WasmObjDir)"
120-
EmSdkPath="$(EMSDK_PATH)"
121-
ConsoleToMsBuild="true"
122-
IgnoreStandardErrorWarningFormat="true">
123-
</RunWithEmSdkEnv>
124-
<ItemGroup>
125-
<WasmBundleTimezonesObjects Include="%(_WasmBundleTimezonesSources.Filename).o" />
126-
</ItemGroup>
127-
<WriteLinesToFile File="$(_WasmTimezonesArchiveRsp)"
128-
Overwrite="true"
129-
Lines="@(WasmBundleTimezonesObjects, ' ')"
130-
WriteOnlyWhenDifferent="true" />
131-
<RunWithEmSdkEnv Command="$(EmSdkLLVMAr) cs -r $(_WasmTimezonesBundleArchive) @$(_WasmTimezonesArchiveRsp)"
132-
EmSdkPath="$(EMSDK_PATH)"
133-
WorkingDirectory="$(WasmObjDir)"
134-
ConsoleToMsBuild="true"
135-
IgnoreStandardErrorWarningFormat="true">
136-
</RunWithEmSdkEnv>
137-
138-
<ItemGroup>
139-
<_WasmArchivedTimezones Include="$(WasmObjDir)\wasm-bundled-timezones.a" />
140-
</ItemGroup>
141-
142-
<!-- Clean up the bundle-objects dir - remove anything we no longer need -->
143-
<ItemGroup>
144-
<_WasmBundleTimezonesToDelete Include="$(_WasmIntermediateOutputPath)*.o" />
145-
<_WasmBundleTimezonesToDelete Include="$(_WasmIntermediateOutputPath)*.c" />
146-
<_WasmBundleTimezonesToDelete Remove="$(WasmObjDir)\$(_WasmTimezonesBundleSourceFile)" />
147-
<_WasmBundleTimezonesToDelete Remove="%(BundledWasmTimezones.DestinationFile)" />
148-
<_WasmBundleTimezonesToDelete Remove="$(WasmObjDir)\%(WasmBundleTimezonesObjects)" />
149-
</ItemGroup>
150-
<Delete Files="@(_WasmBundleTimezonesToDelete)" />
151-
</Target>
15283

15384
<Target Name="GenerateEmccPropsAndRspFiles">
15485

@@ -374,7 +305,7 @@
374305
<!-- This is a documented target that is invoked by developers in their innerloop work. -->
375306
<Target Name="BuildWasmRuntimes"
376307
AfterTargets="Build"
377-
DependsOnTargets="GenerateEmccPropsAndRspFiles;GenerateManagedToNative;GenerateTimezonesArchive;InstallNpmPackages;BuildWithRollup">
308+
DependsOnTargets="GenerateEmccPropsAndRspFiles;GenerateManagedToNative;InstallNpmPackages;BuildWithRollup">
378309

379310
<ItemGroup>
380311
<ICULibNativeFiles Include="$(ICULibDir)/libicuuc.a;
@@ -475,8 +406,7 @@
475406
SkipUnchangedFiles="true" />
476407

477408
<Copy SourceFiles="@(ICULibFiles);
478-
@(ICULibNativeFiles);
479-
@(_WasmArchivedTimezones);"
409+
@(ICULibNativeFiles);"
480410
DestinationFolder="$(NativeBinDir)"
481411
SkipUnchangedFiles="true" />
482412

@@ -519,7 +449,7 @@
519449
DestinationFolder="$(MicrosoftNetCoreAppRuntimePackNativeDir)"
520450
SkipUnchangedFiles="true" />
521451

522-
<Copy SourceFiles="@(IcuDataFiles);@(ICULibNativeFiles);@(_WasmArchivedTimezones)"
452+
<Copy SourceFiles="@(IcuDataFiles);@(ICULibNativeFiles)"
523453
DestinationFolder="$(MicrosoftNetCoreAppRuntimePackNativeDir)"
524454
SkipUnchangedFiles="true" />
525455

src/mono/browser/build/BrowserWasmApp.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,9 @@
328328
<_EmccCFlags Include="-DENABLE_AOT=1" Condition="'$(_WasmShouldAOT)' == 'true'" />
329329
<_EmccCFlags Include="-DDRIVER_GEN=1" Condition="'$(_WasmShouldAOT)' == 'true'" />
330330
<_EmccCFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" />
331-
<_EmccCFlags Include="-DINVARIANT_TIMEZONE=1" Condition="'$(InvariantTimezone)' == 'true'" />
332331
<_EmccCFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" />
333332
<_EmccCFlags Include="-DENABLE_AOT_PROFILER=1" Condition="$(WasmProfilers.Contains('aot'))" />
334-
<_EmccCFlags Include="-DENABLE_DEVTOOLS_PROFILER=1" Condition="$(WasmProfilers.Contains('browser'))" />
333+
<_EmccCFlags Include="-DENABLE_DEVTOOLS_PROFILER=1" Condition="$(WasmProfilers.Contains('browser'))" />
335334
<_EmccCFlags Include="-DENABLE_LOG_PROFILER=1" Condition="$(WasmProfilers.Contains('log'))" />
336335
<_EmccCFlags Include="-DENABLE_JS_INTEROP_BY_VALUE=1" Condition="'$(WasmEnableJsInteropByValue)' == 'true'" />
337336

@@ -459,9 +458,10 @@
459458
</PropertyGroup>
460459

461460
<ItemGroup>
462-
<_MonoRuntimeComponentDontLink Include="wasm-bundled-timezones.a" Condition="'$(InvariantTimezone)' == 'true'"/>
463461
<_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(EnableDiagnostics)' != 'true'" />
464462
<_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-stub-static.lib" Condition="'$(EnableDiagnostics)' == 'true'" />
463+
<_MonoRuntimeComponentDontLink Include="libSystem.Native.TimeZoneData.Invariant.a" Condition="'$(InvariantTimezone)' != 'true'" />
464+
<_MonoRuntimeComponentDontLink Include="libSystem.Native.TimeZoneData.a" Condition="'$(InvariantTimezone)' == 'true'" />
465465
</ItemGroup>
466466

467467
<ItemGroup>

src/mono/browser/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ target_link_libraries(dotnet.native
2626
${MONO_ARTIFACTS_DIR}/libmono-icall-table.a
2727
${MONO_ARTIFACTS_DIR}/libmono-wasm-eh-js.a
2828
${MONO_ARTIFACTS_DIR}/libmono-wasm-${CONFIGURATION_INTERPSIMDTABLES_LIB}.a
29-
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
3029
${NATIVE_BIN_DIR}/libSystem.Native.a
30+
${NATIVE_BIN_DIR}/libSystem.Native.TimeZoneData.a
3131
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a
3232
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a
3333
${NATIVE_BIN_DIR}/libz.a)

src/mono/browser/runtime/driver.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ int monoeg_g_setenv(const char *variable, const char *value, int overwrite);
4444
char *mono_method_get_full_name (MonoMethod *method);
4545
char *mono_method_full_name (MonoMethod *method, int32_t signature);
4646

47-
#ifndef INVARIANT_TIMEZONE
48-
extern void mono_register_timezones_bundle (void);
49-
#endif /* INVARIANT_TIMEZONE */
5047
extern void mono_wasm_set_entrypoint_breakpoint (const char* assembly_name, int method_token);
5148

5249
extern void mono_bundled_resources_add_assembly_resource (const char *id, const char *name, const uint8_t *data, uint32_t size, void (*free_func)(void *, void*), void *free_data);
@@ -193,12 +190,6 @@ mono_wasm_load_runtime (int debug_level, int propertyCount, const char **propert
193190

194191
monovm_initialize (propertyCount, propertyKeys, propertyValues);
195192

196-
#ifndef INVARIANT_TIMEZONE
197-
char* invariant_timezone = monoeg_g_getenv ("DOTNET_SYSTEM_TIMEZONE_INVARIANT");
198-
if (strcmp(invariant_timezone, "true") != 0 && strcmp(invariant_timezone, "1") != 0)
199-
mono_register_timezones_bundle ();
200-
#endif /* INVARIANT_TIMEZONE */
201-
202193
root_domain = mono_wasm_load_runtime_common (debug_level, wasm_trace_logger, interp_opts);
203194

204195
bindings_initialize_internals();

src/mono/wasi/build/WasiApp.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@
253253
<_WasmCommonCFlags Condition="'$(_DriverGenCNeeded)' == 'true'" Include="-DDRIVER_GEN=1" />
254254
<_WasmCommonCFlags Condition="'$(WasmSingleFileBundle)' == 'true'" Include="-DWASM_SINGLE_FILE=1" />
255255
<_WasmCommonCFlags Condition="'$(InvariantGlobalization)' == 'true'" Include="-DINVARIANT_GLOBALIZATION=1" />
256-
<_WasmCommonCFlags Condition="'$(InvariantTimezone)' == 'true'" Include="-DINVARIANT_TIMEZONE=1" />
257256
<_WasmCommonCFlags Condition="'$(WasmLinkIcalls)' == 'true'" Include="-DLINK_ICALLS=1" />
258257
<_WasmCommonCFlags Condition="'$(_IsLibraryMode)' == 'true'" Include="-DWASM_LIBRARY_MODE=1" />
259258
<_WasiClangCFlags Include="@(_WasmCommonCFlags)" />
@@ -365,9 +364,10 @@
365364
</PropertyGroup>
366365

367366
<ItemGroup>
368-
<_MonoRuntimeComponentDontLink Include="wasm-bundled-timezones.a" Condition="'$(InvariantTimezone)' == 'true'"/>
369367
<_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(EnableDiagnostics)' != 'true'" />
370368
<_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-stub-static.lib" Condition="'$(EnableDiagnostics)' == 'true'" />
369+
<_MonoRuntimeComponentDontLink Include="libSystem.Native.TimeZoneData.Invariant.a" Condition="'$(InvariantTimezone)' != 'true'" />
370+
<_MonoRuntimeComponentDontLink Include="libSystem.Native.TimeZoneData.a" Condition="'$(InvariantTimezone)' == 'true'" />
371371
</ItemGroup>
372372

373373
<ItemGroup>

src/mono/wasi/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ target_link_libraries(dotnet
2626
${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a
2727
${MONO_ARTIFACTS_DIR}/libmono-icall-table.a
2828
${MONO_ARTIFACTS_DIR}/libmono-wasm-${CONFIGURATION_INTERPSIMDTABLES_LIB}.a
29-
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
3029
${NATIVE_BIN_DIR}/libSystem.Native.a
30+
${NATIVE_BIN_DIR}/libSystem.Native.TimeZoneData.a
3131
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a
3232
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a
3333
${NATIVE_BIN_DIR}/libz.a

src/mono/wasi/runtime/driver.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ int monoeg_g_setenv(const char *variable, const char *value, int overwrite);
4141
int32_t monoeg_g_hasenv(const char *variable);
4242
void mono_free (void*);
4343
char *mono_method_get_full_name (MonoMethod *method);
44-
#ifndef INVARIANT_TIMEZONE
45-
extern void mono_register_timezones_bundle (void);
46-
#endif /* INVARIANT_TIMEZONE */
4744
#ifdef WASM_SINGLE_FILE
4845
extern void mono_register_assemblies_bundle (void);
4946
extern void mono_register_runtimeconfig_bin (void);
@@ -265,11 +262,6 @@ mono_wasm_load_runtime (int debug_level)
265262
load_runtimeconfig();
266263
monovm_initialize (2, appctx_keys, appctx_values);
267264

268-
#ifndef INVARIANT_TIMEZONE
269-
char* invariant_timezone = monoeg_g_getenv ("DOTNET_SYSTEM_TIMEZONE_INVARIANT");
270-
if (strcmp(invariant_timezone, "true") != 0 && strcmp(invariant_timezone, "1") != 0)
271-
mono_register_timezones_bundle ();
272-
#endif /* INVARIANT_TIMEZONE */
273265
#ifdef WASM_SINGLE_FILE
274266
mono_register_assemblies_bundle ();
275267
#endif

0 commit comments

Comments
 (0)