Skip to content
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
15 changes: 11 additions & 4 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
TSLANG_LIB_PATH: ${{github.workspace}}/__build/tslang/msbuild/x64/release/lib
run: |
$env:VSWHERE_PATH = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
.\build.bat release
.\build.bat
shell: pwsh

- name: Test Default Library
Expand All @@ -177,7 +177,11 @@ jobs:

- name: Create Zip of Windows Asset
working-directory: ${{github.workspace}}/__build
run: Get-ChildItem -Path .\tslang\msbuild\x64\release\bin\tslang.exe, .\tslang\msbuild\x64\release\bin\TypeScriptRuntime.dll, .\gc\msbuild\x64\release\${{ env.BUILD_TYPE }}\gc.lib, .\tslang\msbuild\x64\release\lib\TypeScriptAsyncRuntime.lib, ..\3rdParty\llvm\x64\release\lib\LLVMSupport.lib, ..\3rdParty\llvm\x64\release\bin\wasm-ld.exe, ..\TypeScriptCompilerDefaultLib\__build\release\* | Compress-Archive -DestinationPath ..\tslang.zip
# Flatten the compiler/runtime binaries into the archive root, and add the
# default library as a whole tree so its per-build subfolders are preserved:
# defaultlib/dll/{debug,release}, defaultlib/lib/{debug,release},
# defaultlib/*.d.ts, defaultlib/generics/
run: Get-ChildItem -Path .\tslang\msbuild\x64\release\bin\tslang.exe, .\tslang\msbuild\x64\release\bin\TypeScriptRuntime.dll, .\gc\msbuild\x64\release\${{ env.BUILD_TYPE }}\gc.lib, .\tslang\msbuild\x64\release\lib\TypeScriptAsyncRuntime.lib, ..\3rdParty\llvm\x64\release\lib\LLVMSupport.lib, ..\3rdParty\llvm\x64\release\bin\wasm-ld.exe, ..\TypeScriptCompilerDefaultLib\__build\defaultlib | Compress-Archive -DestinationPath ..\tslang.zip
shell: pwsh

- name: Archive Zip of Windows Asset
Expand Down Expand Up @@ -343,7 +347,7 @@ jobs:
GC_LIB_PATH: ${{github.workspace}}/__build/gc/ninja/release
LLVM_LIB_PATH: ${{github.workspace}}/3rdParty/llvm/release/lib
TSLANG_LIB_PATH: ${{github.workspace}}/__build/tslang/ninja/release/lib
run: chmod +x ./build.sh ./scripts/*.sh; ./build.sh release
run: chmod +x ./build.sh ./scripts/*.sh; ./build.sh

- name: Test Default Library
continue-on-error: false
Expand Down Expand Up @@ -371,7 +375,10 @@ jobs:
cp ../3rdParty/llvm/release/bin/wasm-ld ./__stage/
cp ../3rdParty/llvm/release/lib/libLLVMSupport.a ./__stage/
cp ../3rdParty/llvm/release/lib/libLLVMDemangle.a ./__stage/
cp -r ../TypeScriptCompilerDefaultLib/__build/release/. ./__stage/
# Add the default library as a whole tree so its per-build subfolders are
# preserved: defaultlib/dll/{debug,release}, defaultlib/lib/{debug,release},
# defaultlib/*.d.ts, defaultlib/generics/
cp -r ../TypeScriptCompilerDefaultLib/__build/defaultlib ./__stage/
tar -czvhf ../tslang.tar.gz -C ./__stage .

- name: Archive Tar.GZ of Linux Asset
Expand Down
6 changes: 3 additions & 3 deletions tslang/build_tslang_defaultlib_debug.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pushd
cd ../../TypeScriptCompilerDefaultLib/
call build.bat

xcopy dll\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-debug/bin/defaultlib/dll/" /i /y
xcopy lib\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-debug/bin/defaultlib/lib/" /i /y
xcopy src\*.d.ts "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-debug/bin/defaultlib/" /i /y
rem Copy the whole staged defaultlib tree so per-build subfolders are preserved:
rem defaultlib\dll\{debug,release}, defaultlib\lib\{debug,release}, *.d.ts, generics\
xcopy __build\defaultlib\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-debug/bin/defaultlib/" /i /e /y

popd
6 changes: 3 additions & 3 deletions tslang/build_tslang_defaultlib_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pushd
cd ../../TypeScriptCompilerDefaultLib/
call build.bat

xcopy dll\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-release/bin/defaultlib/dll/" /i /y
xcopy lib\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-release/bin/defaultlib/lib/" /i /y
xcopy src\*.d.ts "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-release/bin/defaultlib/" /i /y
rem Copy the whole staged defaultlib tree so per-build subfolders are preserved:
rem defaultlib\dll\{debug,release}, defaultlib\lib\{debug,release}, *.d.ts, generics\
xcopy __build\defaultlib\*.* "../TypeScriptCompiler/__build/tslang/windows-msbuild-2026-release/bin/defaultlib/" /i /e /y

popd
7 changes: 7 additions & 0 deletions tslang/include/TypeScript/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
#define DEFAULT_LIB_DIR "defaultlib"
#define DEFAULT_LIB_NAME "TypeScriptDefaultLib"

// The compiled default-lib binaries (dll/ and lib/) are stored in per-build
// subfolders so debug and release artifacts can ship side by side. The
// declaration files (*.d.ts, generics/) are build-mode independent and stay at
// the defaultlib root.
#define DEFAULT_LIB_BUILD_DIR_RELEASE "release"
#define DEFAULT_LIB_BUILD_DIR_DEBUG "debug"

#define DEBUG_SCOPE "current"
#define CU_DEBUG_SCOPE "compileUnit"
#define FILE_DEBUG_SCOPE "file"
Expand Down
10 changes: 9 additions & 1 deletion tslang/include/TypeScript/VSCodeTemplate/Files.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,16 @@ enable_language(TSLANG)
# Include folders
include_directories(${CMAKE_TSLANG_DIR}/defaultlib)

# The compiled default lib is split into per-build subfolders (debug/release);
# pick the one matching this build so the CRT and default-lib binaries agree.
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(TSLANG_DEFAULTLIB_BUILD "release")
else()
set(TSLANG_DEFAULTLIB_BUILD "debug")
endif()

# Lib folders
link_directories(${CMAKE_TSLANG_DIR} ${CMAKE_TSLANG_DIR}/defaultlib/lib)
link_directories(${CMAKE_TSLANG_DIR} ${CMAKE_TSLANG_DIR}/defaultlib/lib/${TSLANG_DEFAULTLIB_BUILD})

# set options
if (CMAKE_BUILD_TYPE STREQUAL "Release")
Expand Down
13 changes: 9 additions & 4 deletions tslang/tslang/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,20 +452,25 @@
}
},
{
"name": "(Windows) tslang.exe - EXE(DI)",
"name": "(Windows) tslang.exe - JIT(DI)",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/../../__build/tslang/windows-msbuild-2026-debug/bin/tslang.exe",
"args": [
"-emit=exe",
"-emit=jit",
"--di",
"-mtriple=x86_64-pc-windows-msvc",
"--opt_level=0",
"--nowarn",
"I:/TypeScriptCompilerDefaultLib/tests/array_copyWithin.ts",
"--shared-libs=${workspaceFolder}/../../__build/tslang/windows-msbuild-2026-debug/bin/TypeScriptRuntime.dll",
"I:/TypeScriptCompilerDefaultLib/tests/sleep.ts",
],
"stopAtEntry": false,
"cwd": "I:/Playground",
"environment": [
{
"name": "DEFAULT_LIB_PATH",
"value": "${workspaceFolder}/../../../TypeScriptCompilerDefaultLib/__build/debug"
},
{
"name": "GC_LIB_PATH",
"value": "${workspaceFolder}/../../__build/gc/msbuild/x64/debug/Debug"
Expand Down
32 changes: 20 additions & 12 deletions tslang/tslang/defaultlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "llvm/Support/FormatVariadic.h"

#include "TypeScript/TypeScriptCompiler/Defines.h"
#include "TypeScript/Defines.h"
#include "TypeScript/VSCodeTemplate/Files.h"

#include <cstdlib>
Expand Down Expand Up @@ -52,17 +53,17 @@ std::string getDefaultLibPath();
std::string getpath(std::string, const SmallVectorImpl<char>&);
std::error_code copy_from_to(const SmallVectorImpl<char>&, const SmallVectorImpl<char>&);

bool checkFileExistsAtPath(const SmallVectorImpl<char>& path, std::string sub1, std::string sub2, std::string fileName)
bool checkFileExistsAtPath(const SmallVectorImpl<char>& path, std::string sub1, std::string sub2, std::string sub3, std::string fileName)
{
llvm::SmallVector<char> destPath(0);
destPath.reserve(256);
destPath.append(path);

llvm::sys::path::append(destPath, sub1, sub2, fileName);
llvm::sys::path::append(destPath, sub1, sub2, sub3, fileName);
if (!llvm::sys::fs::exists(destPath))
{
return false;
}
}

return true;
}
Expand Down Expand Up @@ -136,15 +137,18 @@ int installDefaultLib(int argc, char **argv)
return -1;
}

// The release build is always produced; verify its static lib landed in the
// per-build subfolder (defaultlib/lib/release/...).
auto result = checkFileExistsAtPath(
builtPath,
"defaultlib",
"lib",
#ifdef WIN32
"TypeScriptDefaultLib.lib"
builtPath,
DEFAULT_LIB_DIR,
"lib",
DEFAULT_LIB_BUILD_DIR_RELEASE,
#ifdef WIN32
DEFAULT_LIB_NAME ".lib"
#else
"libTypeScriptDefaultLib.a"
#endif
"lib" DEFAULT_LIB_NAME ".a"
#endif
);

if (!result)
Expand Down Expand Up @@ -256,7 +260,9 @@ int buildWin32(const SmallVectorImpl<char>& appPath, SmallVectorImpl<char>& buil
return -1;
}

path::append(builtPath, "__build", "release");
// Staging root holding the shared defaultlib tree (defaultlib/dll/<mode>,
// defaultlib/lib/<mode>, plus mode-independent *.d.ts and generics/).
path::append(builtPath, "__build");

return 0;
}
Expand Down Expand Up @@ -306,7 +312,9 @@ int buildLinux(const SmallVectorImpl<char>& appPath, SmallVectorImpl<char>& buil
return -1;
}

path::append(builtPath, "__build", "release");
// Staging root holding the shared defaultlib tree (defaultlib/dll/<mode>,
// defaultlib/lib/<mode>, plus mode-independent *.d.ts and generics/).
path::append(builtPath, "__build");

return 0;
}
Expand Down
8 changes: 6 additions & 2 deletions tslang/tslang/exe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,12 @@ int buildExe(int argc, char **argv, std::string objFileName, std::string additio
// default lib file
args.push_back("-l" DEFAULT_LIB_NAME);

// default lib path
defaultLibPathOpt = getLibsPathOpt(mergeWithDefaultLibPath(getDefaultLibPath(), shared ? DEFAULT_LIB_DIR "/dll" : DEFAULT_LIB_DIR "/lib"));
// default lib path (per-build subfolder: debug/release must match how
// this program is being compiled so the CRT and default-lib binaries agree).
// Keyed on --di (generate debug info): with debug info use the debug lib.
auto defaultLibBuildDir = compileOptions.generateDebugInfo ? DEFAULT_LIB_BUILD_DIR_DEBUG : DEFAULT_LIB_BUILD_DIR_RELEASE;
auto defaultLibSubDir = std::string(shared ? DEFAULT_LIB_DIR "/dll/" : DEFAULT_LIB_DIR "/lib/") + defaultLibBuildDir;
defaultLibPathOpt = getLibsPathOpt(mergeWithDefaultLibPath(getDefaultLibPath(), defaultLibSubDir));
if (!defaultLibPathOpt.empty())
{
args.push_back(defaultLibPathOpt.c_str());
Expand Down
13 changes: 8 additions & 5 deletions tslang/tslang/jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,15 @@ int runJit(int argc, char **argv, mlir::ModuleOp module, CompileOptions &compile
// engine. Otherwise we'll pass library directly to the execution engine.
if (!compileOptions.noDefaultLib)
{
clSharedLibs.push_back(mergeWithDefaultLibPath(getDefaultLibPath(),
#ifdef WIN32
DEFAULT_LIB_DIR "/dll/" DEFAULT_LIB_NAME ".dll"
// per-build subfolder (debug/release) must match the JIT compilation mode.
// Keyed on --di (generate debug info): with debug info use the debug lib.
auto defaultLibBuildDir = compileOptions.generateDebugInfo ? DEFAULT_LIB_BUILD_DIR_DEBUG : DEFAULT_LIB_BUILD_DIR_RELEASE;
clSharedLibs.push_back(mergeWithDefaultLibPath(getDefaultLibPath(),
#ifdef WIN32
std::string(DEFAULT_LIB_DIR "/dll/") + defaultLibBuildDir + "/" DEFAULT_LIB_NAME ".dll"
#else
DEFAULT_LIB_DIR "/dll/lib" DEFAULT_LIB_NAME ".so"
#endif
std::string(DEFAULT_LIB_DIR "/dll/") + defaultLibBuildDir + "/lib" DEFAULT_LIB_NAME ".so"
#endif
));
}

Expand Down
Loading