Skip to content

Fix makeRemovedFSAssert() resolved path #24567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
runInMacroContext,
pushCurrentFile,
popCurrentFile,
localFile,
warn,
srcDir,
} from './utility.mjs';
Expand Down Expand Up @@ -921,7 +922,7 @@ function makeModuleReceiveWithVar(localName, moduleName, defaultValue) {
function makeRemovedFSAssert(fsName) {
assert(ASSERTIONS);
const lower = fsName.toLowerCase();
if (JS_LIBRARIES.includes(path.resolve(path.join('lib', `lib${lower}.js`)))) return '';
if (JS_LIBRARIES.includes(localFile(path.join('lib', `lib${lower}.js`)))) return '';
return `var ${fsName} = '${fsName} is no longer included by default; build with -l${lower}.js';`;
}

Expand Down
15 changes: 15 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -16234,3 +16234,18 @@ def test_libcxx_errors(self):
# and in debug mode at least we expect to see the error message from libc++
expected = 'system_error was thrown in -fno-exceptions mode with error 6 and message "thread constructor failed"'
self.do_runf('main.cpp', expected, assert_returncode=NON_ZERO)

def test_parsetools_make_removed_fs_assert(self):
"""
This tests that parseTools.mjs `makeRemovedFSAssert()` works as intended,
if it creates a stub when a builtin library isn't included, but not when
it is.
"""

removed_fs_assert_content = "IDBFS is no longer included by default"

self.emcc(test_file('hello_world.c'), output_filename='hello_world.js')
self.assertContained(removed_fs_assert_content, read_file('hello_world.js'))

self.emcc(test_file('hello_world.c'), ['-lidbfs.js'], output_filename='hello_world.js')
self.assertNotContained(removed_fs_assert_content, read_file('hello_world.js'))