Closed Bug 1747145 Opened 2 years ago Closed 1 year ago

Configure should check that linking wasm modules works

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(firefox-esr102- fixed, firefox110 fixed, firefox111 fixed)

RESOLVED FIXED
111 Branch
Tracking Status
firefox-esr102 - fixed
firefox110 --- fixed
firefox111 --- fixed

People

(Reporter: Sylvestre, Assigned: glandium)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

using apt.llvm.org packages:

sudo debootstrap bullseye bullseye.dir
sudo mount -t proc /proc bullseye.dir/proc
sudo mount -t proc /dev/pts bullseye.dir/dev/pts
sudo mount -t tmpfs tmpfs  bullseye.dir/dev/shm
sudo chroot bullseye.dir
apt install mercurial wget lsb-release wget software-properties-common gnupg2 python3-distutils python3-pip
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 14
hg clone https://hg.mozilla.org/mozilla-central/
cd mozilla-central
echo "export CC=clang-14
export  CXX=clang++-14
ac_add_options --enable-bootstrap
" > .mozconfig

./mach bootstrap
./mach build
 0:11.90 /usr/bin/clang++-14 -std=gnu++17 --target=wasm32-wasi --sysroot=/root/.mozbuild/sysroot-wasm32-wasi -o rlbox.wasm -Wl,--export-all -Wl,--stack-first -Wl,-z,stack-size=262144 -Wl,--no-entry -Wl,--growable-table ogg_alloc.wasm ogg_bitwise.wasm ogg_framing.wasm xmlparse.wasm xmlrole.wasm xmltok.wasm wasm2c_sandbox_wrapper.wasm mozHunspellRLBoxSandbox.wasm affentry.wasm affixmgr.wasm csutil.wasm hashmgr.wasm hunspell.wasm phonet.wasm replist.wasm suggestmgr.wasm GraphiteExtra.wasm CmapCache.wasm Code.wasm Collider.wasm Decompressor.wasm Face.wasm FeatureMap.wasm FileFace.wasm Font.wasm GlyphCache.wasm GlyphFace.wasm Intervals.wasm Justifier.wasm NameTable.wasm Pass.wasm Position.wasm Segment.wasm Silf.wasm Slot.wasm Sparse.wasm TtfUtil.wasm UtfCodec.wasm call_machine.wasm gr_char_info.wasm gr_face.wasm gr_features.wasm gr_font.wasm gr_logging.wasm gr_segment.wasm gr_slot.wasm json.wasm RLBoxWOFF2Sandbox.wasm table_tags.wasm variable_length.wasm woff2_common.wasm woff2_dec.wasm woff2_out.wasm -lwasi-emulated-process-clocks
 0:11.93 clang: error: unable to execute command: Executable "wasm-ld" doesn't exist!
 0:11.93 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Type: task → defect

wasm-ld is supposed to come with clang. There's a case to be made that we should check in configure rather than failing later, but there's a problem in your packages if wasm-ld is not there.

ok,
it is:
lld-14: /usr/bin/wasm-ld-14

lld has it:

lld:amd64: /usr/bin/lld
lrwxrwxrwx 1 root root 6 Oct  6 17:55 /usr/bin/lld -> lld-14

it is possible to provide it like CXX=clang++-14 ?

It's clang that is calling it.

Cool, I will tell the debian packager. thanks ;)

Workaround: use /usr/lib/llvm-14/bin/clang as CC (you can unset CXX, it's simpler than also setting it to /usr/lib/llvm-14/bin/clang++)

which fails on the same command, but with a different error:

wasm-ld: error: unable to find library -lgcc

With llvm-11, the error was:

wasm-ld: error: cannot open /usr/lib/llvm-11/lib/clang/11.1.0/lib/wasi/libclang_rt.builtins-wasm32.a: No such file or directory

I suspect it's actually the same problem, but when it doesn't find the clang runtime, it falls back to libgcc. As a matter of fact, if I switch to clang-13, which gives the same unable to find library -lgcc error and copy libclang_rt.builtins-wasm32.a from the mozilla clang into /usr/lib/llvm-13/lib/clang/13.0.1/lib/wasi, it succeeds.

So as far as the error itself is concerned, this is RESOLVED INVALID, but we should definitely emit an error during configure.

(sidenote: we'll need that wasi clang runtime to enable rlbox in Debian too ; I thought I had filed a bug, but I can't find it so maybe I didn't)

Summary: Debian bullseye: fail to build with 'Executable "wasm-ld" doesn't exist!' → Configure should check that linking wasm modules works
Priority: -- → P3

ok, thanks

For people facing this issue, as workaround just add:

ac_add_options --without-wasm-sandboxed-libraries

[Tracking Requested - why for this release]: this caused me build bustage on ESR 102.

I'll take a patch on ESR102 to make life easier for downstream embedders, but I don't see a need to track this either.

Assignee: nobody → mh+mozilla
Status: NEW → ASSIGNED
Attachment #9312536 - Attachment description: Bug 1747145 - Add more configure for the wasm toolchain setup. → Bug 1747145 - Add more configure checks for the wasm toolchain setup.
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/b5d3998c113c
Add more configure checks for the wasm toolchain setup. r=firefox-build-system-reviewers,ahochheiden

Backed out for causing build bustages

Backout link

Push with failures

Failure log

Flags: needinfo?(mh+mozilla)
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/2cd1b61ddd24
Only apply stlport flags to configure compiler executions for target. r=firefox-build-system-reviewers,andi
https://hg.mozilla.org/integration/autoland/rev/3be300874393
Add more configure checks for the wasm toolchain setup. r=firefox-build-system-reviewers,ahochheiden
Flags: needinfo?(mh+mozilla)
Pushed by mh@glandium.org:
https://hg.mozilla.org/integration/autoland/rev/b1326c01f28f
Only apply stlport flags to configure compiler executions for target. r=firefox-build-system-reviewers,andi
https://hg.mozilla.org/integration/autoland/rev/6c47d6018555
Add more configure checks for the wasm toolchain setup. r=firefox-build-system-reviewers,ahochheiden
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch

Comment on attachment 9312536 [details]
Bug 1747145 - Add more configure checks for the wasm toolchain setup.

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Build-only change that is a no-op in practice for most builds. It is preliminary to bug 1810627, which allows downstreams like Debian to enable wasm sandboxing with their packaged wasi SDK.
  • User impact if declined: See above
  • Fix Landed on Version: 111
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): See above

Beta/Release Uplift Approval Request

  • User impact if declined: See ESR request
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: Bug 1810627
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): See ESR request
  • String changes made/needed: N/A
  • Is Android affected?: No
Attachment #9312536 - Flags: approval-mozilla-esr102?
Attachment #9312536 - Flags: approval-mozilla-beta?
Attachment #9312762 - Flags: approval-mozilla-esr102?

Comment on attachment 9312762 [details]
Bug 1747145 - Only apply stlport flags to configure compiler executions for target.

Beta/Release Uplift Approval Request

  • User impact if declined: See other request in the same bug
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky):
  • String changes made/needed:
  • Is Android affected?: Yes
Attachment #9312762 - Flags: approval-mozilla-beta?
Blocks: 1810627

Comment on attachment 9312536 [details]
Bug 1747145 - Add more configure checks for the wasm toolchain setup.

Approved for 110 beta 4, thanks.

Attachment #9312536 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9312762 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment on attachment 9312536 [details]
Bug 1747145 - Add more configure checks for the wasm toolchain setup.

Approved for 102.8esr.

Attachment #9312536 - Flags: approval-mozilla-esr102? → approval-mozilla-esr102+
Attachment #9312762 - Flags: approval-mozilla-esr102? → approval-mozilla-esr102+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: