Skip to content

Commit 0a19d75

Browse files
authored
Merge pull request #4438 from BuckleScript/tweak
tweak post-processing
2 parents 2e8eab0 + 14153aa commit 0a19d75

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

jscomp/snapshot.ninja

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,45 @@ SNAP=../lib/$snapshot_path
1717

1818
build snapshot: phony $SNAP/whole_compiler.ml $SNAP/bsb_helper.ml $SNAP/bsb.ml $SNAP/bspp.ml $SNAP/unstable/all_ounit_tests.ml
1919

20-
build $SNAP/whole_compiler.ml: bspack | ./bin/bspack.exe
20+
build $SNAP/whole_compiler.ml: bspack | ./bin/bspack.exe $LTO
2121
flags = ${releaseMode} -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER ${includes}
2222
main = Js_main
2323
post_process = && node $LTO $SNAP/whole_compiler.ml
2424

25-
26-
27-
build $SNAP/bsb_helper.ml: bspack | ./bin/bspack.exe
25+
build $SNAP/bsb_helper.ml: bspack | ./bin/bspack.exe $LTO
2826
flags = -bs-MD ${releaseMode} -I stubs -I common -I ext -I syntax -I depends -I bsb_helper -I main
2927
main = Bsb_helper_main
3028

31-
build $SNAP/bsb.ml: bspack | ./bin/bspack.exe
29+
build $SNAP/bsb.ml: bspack | ./bin/bspack.exe $LTO
3230
flags = -D BS_MIN_LEX_DEPS=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I main
3331
main = Bsb_main
3432

35-
36-
build $SNAP/bspp.ml: bspack | ./bin/bspack.exe
33+
build $SNAP/bspp.ml: bspack | ./bin/bspack.exe $LTO
3734
flags = -D BS_MIN_LEX_DEPS=true ${releaseMode} -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING?parser -I common -I ext -I syntax -I depends -I bspp -I core -I main
3835
main = Bspp_main
3936

40-
build $SNAP/unstable/bsb_native.ml: bspack | ./bin/bspack.exe
37+
build $SNAP/unstable/bsb_native.ml: bspack | ./bin/bspack.exe $LTO
4138
flags = -D BS_MIN_LEX_DEPS=true -D BS_NATIVE=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I main
4239
main = Bsb_main
4340

44-
build $SNAP/unstable/native_ppx.ml: bspack | ./bin/bspack.exe
41+
build $SNAP/unstable/native_ppx.ml: bspack | ./bin/bspack.exe $LTO
4542
flags = -module-alias Config=Config_whole_compiler -D BS_MIN_LEX_DEPS=true -D BS_NATIVE=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I core -I main
4643
main = Native_ppx_main
4744

4845

49-
build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe
46+
build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe $LTO
5047
flags = -bs-MD -I ounit -I ounit_tests -I stubs -I bsb -I bsb_helper -I common -I ext -I syntax -I depends -I bspp -I core -I main
5148
main = Ounit_tests_main
5249

53-
build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe
50+
build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe $LTO
5451
flags = -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_PARSING -I $OCAML_SRC_UTILS -I stubs -I ext -I common -I depends -I core -I main -bs-main Bspack_main
5552
main = Bspack_main
5653

57-
build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe
54+
build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe $LTO
5855
flags = -D BS_BROWSER=true -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer -I js_parser -I main
5956
main = Jsoo_main
6057

61-
build $SNAP/unstable/js_refmt_compiler.ml: bspack | ./bin/bspack.exe
58+
build $SNAP/unstable/js_refmt_compiler.ml: bspack | ./bin/bspack.exe $LTO
6259
flags = -D BS_BROWSER=true -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER -I js_parser -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer -I js_parser -I main -I refmt
6360
main = Jsoo_refmt_main
6461

lib/4.06.1/whole_compiler.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,7 +4589,7 @@ let absolute_path s = (* This function could go into Filename *)
45894589
aux s
45904590

45914591
let show_filename file =
4592-
if !absname then absolute_path file else file
4592+
if true then absolute_path file else file
45934593

45944594
let print_filename ppf file =
45954595
Format.fprintf ppf "%s" (show_filename file)
@@ -362623,7 +362623,7 @@ let read_one_param ppf position name v =
362623362623
set "remove-unused-arguments" [ remove_unused_arguments ] v
362624362624

362625362625
| "inlining-report" ->
362626-
if !native_code then
362626+
if false then
362627362627
set "inlining-report" [ inlining_report ] v
362628362628

362629362629
| "flambda-verbose" ->
@@ -362679,7 +362679,7 @@ let read_one_param ppf position name v =
362679362679

362680362680

362681362681
| "cmo" | "cma" ->
362682-
if not !native_code then
362682+
if not false then
362683362683
begin
362684362684
match position with
362685362685
| Before_link | Before_compile _ ->
@@ -362689,7 +362689,7 @@ let read_one_param ppf position name v =
362689362689
end
362690362690

362691362691
| "cmx" | "cmxa" ->
362692-
if !native_code then
362692+
if false then
362693362693
begin
362694362694
match position with
362695362695
| Before_link | Before_compile _ ->
@@ -362699,7 +362699,7 @@ let read_one_param ppf position name v =
362699362699
end
362700362700

362701362701
| "pic" ->
362702-
if !native_code then
362702+
if false then
362703362703
set "pic" [ pic_code ] v
362704362704

362705362705
| "can-discard" ->
@@ -362886,7 +362886,7 @@ let process_action
362886362886
else if Filename.check_suffix name Config.ext_obj
362887362887
|| Filename.check_suffix name Config.ext_lib then
362888362888
ccobjs := name :: !ccobjs
362889-
else if not !native_code && Filename.check_suffix name Config.ext_dll then
362889+
else if not false && Filename.check_suffix name Config.ext_dll then
362890362890
dllibs := name :: !dllibs
362891362891
else
362892362892
raise(Arg.Bad("don't know what to do with " ^ name))

scripts/buckle_lto.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,29 @@ var pairs = [
77
["Clflags.unsafe_string", "false"],
88
["Clflags.record_event_when_debug", "false"],
99
["Clflags.no_std_include", "true"],
10-
["no_std_include", "true"],
1110
["Clflags.use_threads", "false"],
1211
["Clflags.use_vmthreads", "false"],
1312
["Clflags.no_implicit_current_dir", "true"],
1413
["Clflags.strict_sequence", "true"],
1514
["Clflags.strict_formats", "true"],
15+
["Location.absname", "true"],
1616
];
1717

18-
var regexp = RegExp(`${pairs.map((x) => "!" + x[0]).join("|")}`, "g");
18+
var regexp = RegExp(
19+
`${pairs
20+
.map((x) => {
21+
let result = [];
22+
result.push("!" + x[0]);
23+
let xs = x[0].split(".");
24+
if (xs.length === 2 && xs[1]) {
25+
result.push("!" + xs[1]);
26+
}
27+
return result;
28+
})
29+
.flat()
30+
.join("|")}`,
31+
"g"
32+
);
1933

2034
/**
2135
*
@@ -24,7 +38,8 @@ var regexp = RegExp(`${pairs.map((x) => "!" + x[0]).join("|")}`, "g");
2438
function transform(s) {
2539
return s.replace(regexp, (s) => {
2640
for (let [k, v] of pairs) {
27-
if (s.includes(k)) {
41+
if (s.includes(k.split(".")[1])) {
42+
// "bs_only" instead of "Clflags.bs_only"
2843
return v;
2944
}
3045
}
@@ -33,7 +48,7 @@ function transform(s) {
3348
}
3449
// transform('!Config.bs_only && Clflags.native && !Clflags.native')
3550
var file = process.argv[2];
36-
console.log(`post processing file`, file);
51+
console.log(`POST-PROCESSING-FILE:`, file);
3752
fs.writeFileSync(
3853
file,
3954

0 commit comments

Comments
 (0)