Skip to content

Commit 1850b75

Browse files
authored
Remove some magic handling of native shared libraries (#20886)
We had this rather strange (I imagine completely unused) feature where is emscripten is passed a concrete path to a shared library file (e.g. /path/to/libfoo.so) and it could determine that the shared library was not indented for emscripten then it would instead search the library for other things called `libfoo` that might work. This seems too magical at best and harmful/confusing a worst. The presence of this feature is blocking the way for some internal optimizations and refactorings (e.g. #20884)
1 parent a381606 commit 1850b75

File tree

3 files changed

+12
-37
lines changed

3 files changed

+12
-37
lines changed

ChangeLog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ See docs/process.md for more on how version tagging works.
2323
- Support for explicitly targeting the legacy Interet Explorer or EdgeHTML
2424
(edge version prior to the chromium-based edge) browsers via
2525
`-sMIN_EDGE_VERSION/-sMIN_IE_VERSION` was removed. (#20881)
26+
- Emscripten is now more strict about handling unsupported shared library
27+
inputs. For example, under the old behaviour if a system shared library
28+
such as `/usr/lib/libz.so` was passed to emscripten it would silently re-write
29+
this to `-lz`, which would then search this a libz in its own sysroot. Now
30+
this file is passed though the linker like any other input file and you will
31+
see an `unknown file type` error from the linker (just like you would with the
32+
native clang or gcc toolchains). (#20886)
33+
- Support for explicitly targeting the legacy EdgeHTML browser (edge version
34+
prior to the chromium-based edge) via `-sMIN_EDGE_VERSION` was removed.
35+
Using `-sLEGACY_VM_SUPPORT` should still work if anyone still wanted to target
36+
this or any other legacy browser.
2637
- Breaking change: Using the `*glGetProcAddress()` family of functions now
2738
requires passing a linker flag -sGL_ENABLE_GET_PROC_ADDRESS. This prevents
2839
ports of native GL renderers from later accidentally attempting to activate

emcc.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,7 @@ def phase_setup(options, state, newargs):
761761
else:
762762
message = arg + ': Unknown format, not a static library!'
763763
exit_with_error(message)
764-
if file_suffix in DYNAMICLIB_ENDINGS and not building.is_bitcode(arg) and not building.is_wasm(arg):
765-
# For shared libraries that are neither bitcode nor wasm, assuming its local native
766-
# library and attempt to find a library by the same name in our own library path.
767-
# TODO(sbc): Do we really need this feature? See test_other.py:test_local_link
768-
libname = removeprefix(get_library_basename(arg), 'lib')
769-
flag = '-l' + libname
770-
diagnostics.warning('map-unrecognized-libraries', f'unrecognized file type: `{arg}`. Mapping to `{flag}` and hoping for the best')
771-
state.add_link_flag(i, flag)
772-
else:
773-
input_files.append((i, arg))
764+
input_files.append((i, arg))
774765
elif arg.startswith('-L'):
775766
state.add_link_flag(i, arg)
776767
newargs[i] = ''

test/test_other.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,33 +1642,6 @@ def test_abspaths(self):
16421642
WARNING = 'encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)'
16431643
self.assertContainedIf(WARNING, proc.stderr, expected)
16441644

1645-
def test_local_link(self):
1646-
# Linking a local library directly, like /usr/lib/libsomething.so, cannot work of course since it
1647-
# doesn't contain bitcode. However, when we see that we should look for a bitcode file for that
1648-
# library in the -L paths and system/lib
1649-
create_file('main.c', '''
1650-
extern void printey();
1651-
int main() {
1652-
printey();
1653-
return 0;
1654-
}
1655-
''')
1656-
1657-
ensure_dir('subdir')
1658-
create_file('subdir/libfile.so.1.2.3', 'this is not llvm bitcode!')
1659-
1660-
create_file('libfile.c', '''
1661-
#include <stdio.h>
1662-
void printey() {
1663-
printf("hello from lib\\n");
1664-
}
1665-
''')
1666-
1667-
self.run_process([EMCC, 'libfile.c', '-shared', '-o', 'libfile.so'], stderr=PIPE)
1668-
err = self.run_process([EMCC, 'main.c', Path('subdir/libfile.so.1.2.3'), '-L.'], stderr=PIPE).stderr
1669-
self.assertContained('Mapping to `-lfile` and hoping for the best [-Wmap-unrecognized-libraries]', err)
1670-
self.assertContained('hello from lib', self.run_js('a.out.js'))
1671-
16721645
def test_identical_basenames(self):
16731646
# Issue 287: files in different dirs but with the same basename get confused as the same,
16741647
# causing multiply defined symbol errors

0 commit comments

Comments
 (0)