From e097a5bcbc91bd6297557a7f6c29708639a79548 Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Tue, 20 Oct 2026 10:56:19 +0100 Subject: [PATCH] The default library's folder is searched when it is linked by path #609 links the static default library by its full path and dropped its -L. On Linux libTypeScriptDefaultLib.a is a GNU ld script, INPUT(-lTypeScriptDefaultLibCore -lcurl), whose archive the linker looks up through the -L paths: every --emit=exe with the default library failed with "cannot find -lTypeScriptDefaultLibCore" (v0.0-pre-alpha105 release, Linux). Co-Authored-By: Claude Opus 5.5 --- tslang/tslang/exe.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tslang/tslang/exe.cpp b/tslang/tslang/exe.cpp index 762cd094b..17aa60582 100644 --- a/tslang/tslang/exe.cpp +++ b/tslang/tslang/exe.cpp @@ -864,6 +864,9 @@ int buildExe(int argc, char **argv, std::string objFileName, std::string additio // The static library by its path: the file the borrow facts were read from // (borrowfacts.cpp) is the file linked, never one of that name the linker finds first, // such as a stray copy in the current folder. The DLL's import library is searched for. + // Its folder is searched either way: on Linux libTypeScriptDefaultLib.a is a GNU ld + // script, INPUT(-lTypeScriptDefaultLibCore -lcurl), whose archive the linker looks up + // there. if (!sharedDefaultLib && !defaultLibDir.empty()) { defaultLibFile = getDefaultLibBinary(/*shared=*/false, compileOptions, TheTriple); @@ -872,11 +875,12 @@ int buildExe(int argc, char **argv, std::string objFileName, std::string additio else { args.push_back("-l" DEFAULT_LIB_NAME); - defaultLibPathOpt = getLibsPathOpt(defaultLibDir); - if (!defaultLibPathOpt.empty()) - { - args.push_back(defaultLibPathOpt.c_str()); - } + } + + defaultLibPathOpt = getLibsPathOpt(defaultLibDir); + if (!defaultLibPathOpt.empty()) + { + args.push_back(defaultLibPathOpt.c_str()); } }