Skip to content

Commit 91bd2ed

Browse files
committed
Remove lto for quickjs
It caused issues on FreeBSD before and we also noticed it failing in an RHEL container with this error: ``` -lm -lpthread -ldl make[2]: *** write jobserver: Bad file descriptor. Stop. make[2]: *** Waiting for unfinished jobs.... make[2]: *** write jobserver: Bad file descriptor. Stop. ``` It seems to be due to an interaction between the `-j` flag and `CONFIG_LTO=y`. My initial thought was to remove the `-j` flag, however after running the quickjs `make microbench` it turns out `CONFIG_LTO=y` wasn't adding much of a speed up, and even was slower on Linux. So let's remove it for now and unify the environment with FreeBSD into a single Unix env. Leave a note in the comments if something changes in the future and we wanted to give it another try.
1 parent 1c33ad5 commit 91bd2ed

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/couch_quickjs/rebar.config.script

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
% Windows is "special" so we treat it "specially"
1616
Msys = "msys2_shell.cmd -defterm -no-start -ucrt64 -here -lc ".
1717

18+
% Disabled CONFIG_LTO=y as of June 2025. It interfered with -j8 and microbench
19+
% on quickjs repo didn't show any measurable per benefit for it. It even looked
20+
% a bit slower on ubuntu-noble/x86_64 (lto:9032ns vs nolto:8746ns) and only a
21+
% tiny bit faster on MacOS x86_64 (lto:12646 vs nolto:12614)
22+
%
1823
PreHooks = [
19-
{"(linux|darwin)", compile, "make CONFIG_LTO=y -C quickjs -j8 libquickjs.lto.a qjsc"},
24+
{"(linux|darwin)", compile, "make -C quickjs -j8 libquickjs.a qjsc"},
2025
{"freebsd", compile, "gmake -C quickjs -j8 libquickjs.a qjsc"},
2126
{"win32", compile, Msys ++ "'make -C quickjs -j8 libquickjs.a qjsc.exe'"},
2227
{"(linux|darwin|freebsd|win32)", compile, "escript build_js.escript compile"}
@@ -38,14 +43,9 @@ ResetFlags = [
3843
{"EXE_LDFLAGS", ""}
3944
].
4045

41-
LinuxDarwinEnv = [
42-
{"CFLAGS", "$CFLAGS -flto -g -Wall -DCONFIG_LTO=y -O2 -Iquickjs"},
43-
{"LDFLAGS", "$LDFLAGS -flto -lm quickjs/libquickjs.lto.a"}
44-
] ++ ResetFlags.
45-
46-
FreeBSDEnv = [
46+
UnixEnv = [
4747
{"CFLAGS", "$CFLAGS -g -Wall -O2 -Iquickjs"},
48-
{"LDFLAGS", "$LDFLAGS -lm -lpthread quickjs/libquickjs.a"}
48+
{"LDFLAGS", "$LDFLAGS quickjs/libquickjs.a -lpthread -lm"}
4949
] ++ ResetFlags.
5050

5151
WindowsEnv = [
@@ -73,10 +73,8 @@ WindowsMainjsSrc = WindowsBaseSrc ++ UnixMainjsSrc.
7373
WindowsCoffeeSrc = WindowsBaseSrc ++ UnixCoffeeSrc.
7474

7575
PortSpecs = [
76-
{"(linux|darwin)", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, LinuxDarwinEnv}]},
77-
{"(linux|darwin)", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, LinuxDarwinEnv}]},
78-
{"freebsd", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, FreeBSDEnv}]},
79-
{"freebsd", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, FreeBSDEnv}]},
76+
{"(linux|darwin|freebsd)", "priv/couchjs_mainjs", UnixMainjsSrc, [{env, UnixEnv}]},
77+
{"(linux|darwin|freebsd)", "priv/couchjs_coffee", UnixCoffeeSrc, [{env, UnixEnv}]},
8078
{"win32", "priv/couchjs_mainjs.exe", WindowsMainjsSrc, [{env, WindowsEnv}]},
8179
{"win32", "priv/couchjs_coffee.exe", WindowsCoffeeSrc, [{env, WindowsEnv}]}
8280
].

0 commit comments

Comments
 (0)