From 88dd214e3d46214e550231955fd502a236817919 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Fri, 13 Jun 2025 18:17:03 -0400 Subject: [PATCH] Fix `makeRemovedFSAssert()` resolved path --- src/parseTools.mjs | 3 ++- test/test_other.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/parseTools.mjs b/src/parseTools.mjs index 1aaa63db12655..b6c6d4d4191a8 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -19,6 +19,7 @@ import { runInMacroContext, pushCurrentFile, popCurrentFile, + localFile, warn, srcDir, } from './utility.mjs'; @@ -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';`; } diff --git a/test/test_other.py b/test/test_other.py index 9c0698097094e..8ad41a99ba936 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -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'))