Skip to content

Commit 07ec7fc

Browse files
Link libcurl on Linux for default lib HTTP support; add JIT default-lib launch config
Default lib's http_linux.cpp depends on libcurl, mirroring the WinHTTP link on Windows. Warn with the install command if the dev package isn't found, then still pass -lcurl so the linker surfaces the error if it's truly missing. Also add a VS Code launch config for JIT-running the default lib's sleep.ts test on Linux. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 6414d7f commit 07ec7fc

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

tslang/tslang/.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,33 @@
980980
],
981981
"visualizerFile": "${workspaceFolder}/../tslang.natvis"
982982
},
983+
{
984+
"name": "(Linux) tslang - JIT (Default Lib - linux file)",
985+
"type": "cppdbg",
986+
"request": "launch",
987+
"program": "${workspaceFolder}/../../__build/tslang/linux-ninja-gcc-debug/bin/tslang",
988+
"args": [
989+
"-emit=jit",
990+
"${workspaceFolder}/../../../TypeScriptCompilerDefaultLib/tests/sleep.ts"
991+
],
992+
"stopAtEntry": false,
993+
"cwd": "${workspaceFolder}",
994+
"environment": [
995+
{
996+
"name": "GC_LIB_PATH",
997+
"value": "${workspaceFolder}/../../__build/gc/ninja/debug"
998+
},
999+
{
1000+
"name": "LLVM_LIB_PATH",
1001+
"value": "${workspaceFolder}/../../__build/llvm/ninja/debug/lib"
1002+
},
1003+
{
1004+
"name": "TSLANG_LIB_PATH",
1005+
"value": "${workspaceFolder}/../../__build/tslang/linux-ninja-gcc-debug/lib"
1006+
}
1007+
],
1008+
"visualizerFile": "${workspaceFolder}/../tslang.natvis"
1009+
},
9831010
{
9841011
"name": "(Windows) tslang.exe - DefaultLib Compile (DLL)",
9851012
"type": "cppvsdbg",

tslang/tslang/exe.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,43 @@ int buildExe(int argc, char **argv, std::string objFileName, std::string additio
515515
args.push_back("-ltinfo");
516516
args.push_back("-ldl");
517517
args.push_back("-lrt");
518+
519+
// The default library's HTTP wrapper (http_linux.cpp) is implemented on
520+
// top of libcurl (the Linux counterpart of WinHTTP on Windows, which is
521+
// linked via a #pragma in http.cpp). Only needed when the default library
522+
// is actually linked, so this is skipped under --no-default-lib. Warn
523+
// early with the exact install command if the development library is not
524+
// present, then still pass -lcurl so the linker error is emitted too if
525+
// it really is missing.
526+
if (!compileOptions.noDefaultLib)
527+
{
528+
static const char *curlSharedLibs[] = {
529+
"/usr/lib/x86_64-linux-gnu/libcurl.so",
530+
"/usr/lib/aarch64-linux-gnu/libcurl.so",
531+
"/usr/lib/libcurl.so",
532+
"/usr/local/lib/libcurl.so",
533+
"/usr/lib64/libcurl.so",
534+
};
535+
536+
bool curlFound = false;
537+
for (auto *curlLib : curlSharedLibs)
538+
{
539+
if (llvm::sys::fs::exists(curlLib))
540+
{
541+
curlFound = true;
542+
break;
543+
}
544+
}
545+
546+
if (!curlFound)
547+
{
548+
llvm::WithColor::warning(llvm::errs(), "tslang")
549+
<< "the curl development library was not found; the HTTP support in the default "
550+
"library needs it. Install it with: sudo apt install libcurl4-openssl-dev\n";
551+
}
552+
553+
args.push_back("-lcurl");
554+
}
518555
//args.push_back("-rdynamic"); // do we need it?
519556
}
520557

0 commit comments

Comments
 (0)