Skip to content

Commit b190913

Browse files
eyebrowsoffireCommit Queue
authored and
Commit Queue
committed
Reland "[dart2wasm] Include wasm-opt in the shipped dart-sdk."
This is a reland of commit 6271d26 The change broke the gcc riscv64 builders, due to a `unused-variable` warning coming from binaryen sources. That warning has now been disabled for binaryen targets. Original change's description: > [dart2wasm] Include wasm-opt in the shipped dart-sdk. > > Change-Id: Ib224f0b92fa28019ad3cf67d7ba2bef5c31b92ef > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280840 > Reviewed-by: Martin Kustermann <[email protected]> > Commit-Queue: Jackson Gardner <[email protected]> > Reviewed-by: Aske Simon Christensen <[email protected]> Change-Id: I76bf4ad5d1f6a8116631df4b91cbc5a52cac4f31 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283240 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Jackson Gardner <[email protected]>
1 parent b35443b commit b190913

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

build/config/compiler/BUILD.gn

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,12 @@ if (is_win) {
610610
default_warning_flags += [
611611
"-Wno-tautological-constant-compare",
612612
"-Wno-unused-but-set-variable", # icu
613-
"-Wno-unused-but-set-parameter", # binaryen
614613
"-Wno-deprecated-non-prototype", # zlib
615614
]
616615
} else {
617-
default_warning_flags +=
618-
[ "-Wno-ignored-qualifiers" ] # Warnings in BoringSSL headers
616+
default_warning_flags += [
617+
"-Wno-ignored-qualifiers", # Warnings in BoringSSL headers
618+
]
619619
}
620620

621621
if (is_mac) {
@@ -729,6 +729,15 @@ config("no_rtti") {
729729
}
730730
}
731731

732+
config("enable_exceptions") {
733+
if (is_win) {
734+
cflags_cc = [ "/EHsc" ]
735+
defines = [ "_HAS_EXCEPTIONS=1" ]
736+
} else if (is_clang) {
737+
cflags_cc = [ "-fexceptions" ]
738+
}
739+
}
740+
732741
# Optimization -----------------------------------------------------------------
733742
#
734743
# Note that BUILDCONFIG.gn sets up a variable "default_optimization_config"

build/toolchain/win/tool_wrapper.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import os
11+
import pathlib
1112
import re
1213
import shutil
1314
import subprocess
@@ -149,7 +150,28 @@ def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
149150
not line.startswith('Generating code') and
150151
not line.startswith('Finished generating code')):
151152
print(line)
152-
return link.wait()
153+
link_result = link.wait()
154+
155+
if link_result != 0:
156+
return link_result
157+
158+
# The toolchain configuration in gn always expects a .lib file to be
159+
# included in the output of the link step. However, this only happens
160+
# when the output has exports, and that is not always the case. In
161+
# order to satisfy the expected outputs, we create a dummy .lib file
162+
# in cases where the link step didn't actually create one.
163+
for arg in args:
164+
m = _LINK_EXE_OUT_ARG.match(arg)
165+
if m:
166+
output_filename = m.group('out')
167+
(basename, extension) = os.path.splitext(output_filename)
168+
if extension == '.exe':
169+
lib_path = pathlib.Path(basename + ".lib")
170+
if not os.path.exists(lib_path):
171+
lib_path.touch()
172+
break
173+
174+
return link_result
153175

154176
def ExecMidlWrapper(self, arch, outdir, tlb, h, dlldata, iid, proxy, idl,
155177
*flags):

sdk/BUILD.gn

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ declare_args() {
2727
dart_precompiled_runtime_stripped_binary = "dart_precompiled_runtime_product"
2828
gen_snapshot_stripped_binary = "gen_snapshot_product"
2929
analyze_snapshot_binary = "analyze_snapshot"
30+
wasm_opt_stripped_binary = "wasm-opt"
3031
}
3132

3233
# The directory layout of the SDK is as follows:
@@ -518,6 +519,16 @@ copy("copy_dart2wasm_snapshot") {
518519
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
519520
}
520521

522+
copy("copy_wasm_opt") {
523+
visibility = [ ":create_full_sdk" ]
524+
deps = [
525+
":copy_libraries",
526+
"../third_party/binaryen:wasm-opt",
527+
]
528+
sources = [ "$root_out_dir/${wasm_opt_stripped_binary}${executable_suffix}" ]
529+
outputs = [ "$root_out_dir/$dart_sdk_output/bin/utils/{{source_file_part}}" ]
530+
}
531+
521532
# Copies DDC's SDK full and outline .dill files to lib/_internal.
522533
copy("copy_dev_compiler_dills") {
523534
visibility = [ ":copy_dev_compiler_sdk" ]
@@ -755,6 +766,7 @@ group("create_full_sdk") {
755766
public_deps += [
756767
":copy_dart2wasm_platform",
757768
":copy_dart2wasm_snapshot",
769+
":copy_wasm_opt",
758770
]
759771
}
760772
}

third_party/binaryen/BUILD.gn

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
import("../../sdk_args.gni")
66

7+
config("binaryen_warnings") {
8+
if (is_clang) {
9+
cflags = [ "-Wno-unused-but-set-parameter" ]
10+
} else if (!is_win) {
11+
cflags = [ "-Wno-unused-variable" ]
12+
}
13+
}
14+
715
action("generate_needed_files") {
816
script = "generate_needed_files.py"
917

@@ -59,6 +67,11 @@ source_set("binaryen_sources") {
5967

6068
# Ensure generated config.h file is include path.
6169
include_dirs += [ "$target_gen_dir" ]
70+
71+
configs += [
72+
"//build/config/compiler:enable_exceptions",
73+
":binaryen_warnings",
74+
]
6275
}
6376

6477
template("wasm_tool") {
@@ -72,6 +85,11 @@ template("wasm_tool") {
7285
include_dirs = [ "src/src" ]
7386
deps = [ ":binaryen_sources" ]
7487
forward_variables_from(invoker, "*")
88+
89+
configs += [
90+
"//build/config/compiler:enable_exceptions",
91+
":binaryen_warnings",
92+
]
7593
}
7694
}
7795

tools/gn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def ToGnArgs(args, mode, arch, target_os, sanitizer, verify_sdk_hash):
300300
gn_args['gen_snapshot_stripped_binary'] = (
301301
'exe.stripped/gen_snapshot_product')
302302
gn_args['analyze_snapshot_binary'] = ('exe.stripped/analyze_snapshot')
303+
gn_args['wasm_opt_stripped_binary'] = 'exe.stripped/wasm-opt'
303304

304305
# Setup the user-defined sysroot.
305306
if UseSysroot(args, gn_args):

0 commit comments

Comments
 (0)