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
4 changes: 2 additions & 2 deletions prepare_3rdParty.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ IF EXIST ".\3rdParty\gc\x64\%BUILD%\lib\gc.lib" (
) ELSE (
cd %p%
echo "Downloading BDWGC"
curl -o gc-%GC_VER%.tar.gz https://github.com/bdwgc/bdwgc/releases/download/v%GC_VER%/gc-%GC_VER%.tar.gz
curl -o gc-%GC_VER%.tar.gz -L https://github.com/bdwgc/bdwgc/releases/download/v%GC_VER%/gc-%GC_VER%.tar.gz
echo "Opening TAR.GZ BDWGC"
tar -xvzf gc-%GC_VER%.tar.gz -C ./3rdParty/
echo "Downloading Libatomic_ops"
curl -o libatomic_ops-%LIBATOMIC_OPS_VER%.tar.gz https://github.com/bdwgc/libatomic_ops/releases/download/v%LIBATOMIC_OPS_VER%/libatomic_ops-%LIBATOMIC_OPS_VER%.tar.gz
curl -o libatomic_ops-%LIBATOMIC_OPS_VER%.tar.gz -L https://github.com/bdwgc/libatomic_ops/releases/download/v%LIBATOMIC_OPS_VER%/libatomic_ops-%LIBATOMIC_OPS_VER%.tar.gz
echo "Opening TAR.GZ Libatomic_ops"
tar -xvzf libatomic_ops-%LIBATOMIC_OPS_VER%.tar.gz -C ./3rdParty/
echo "Copy to gc-%GC_VER%/libatomic_ops"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_gc_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mkdir -p __build/gc/ninja/debug
mkdir -p 3rdParty/gc/debug
cd __build/gc/ninja/debug
cmake ../../../../3rdParty/gc-8.2.8 -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/debug -Denable_threads=ON -Denable_cplusplus=OFF
cmake ../../../../3rdParty/gc-8.2.12 -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/debug -Denable_threads=ON -Denable_cplusplus=OFF
cmake --build . --config Debug -j 16
cmake --install . --config Debug
2 changes: 1 addition & 1 deletion scripts/build_gc_debug_ninja.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pushd
mkdir __build\gc\ninja\debug
cd __build\gc\ninja\debug
cmake ../../../../3rdParty/gc-8.2.8 -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/debug -Denable_threads=ON -Denable_cplusplus=OFF
cmake ../../../../3rdParty/gc-8.2.12 -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/debug -Denable_threads=ON -Denable_cplusplus=OFF
cmake --build . --config Debug -j 8
cmake --install . --config Debug
popd
2 changes: 1 addition & 1 deletion scripts/build_gc_debug_vs.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pushd
mkdir __build\gc\msbuild\x64\debug
cd __build\gc\msbuild\x64\debug
cmake ../../../../../3rdParty/gc-8.2.8 -G "Visual Studio 18 2026" -A x64 %EXTRA_PARAM% -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX=../../../../../3rdParty/gc/x64/debug -Denable_threads=ON -Denable_cplusplus=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake ../../../../../3rdParty/gc-8.2.12 -G "Visual Studio 18 2026" -A x64 %EXTRA_PARAM% -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX=../../../../../3rdParty/gc/x64/debug -Denable_threads=ON -Denable_cplusplus=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build . --config Debug -j 20
cmake --install . --config Debug
popd
2 changes: 1 addition & 1 deletion scripts/build_gc_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
mkdir -p __build/gc/ninja/release
mkdir -p 3rdParty/gc/release
cd __build/gc/ninja/release
cmake ../../../../3rdParty/gc-8.2.8 -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/release -Denable_threads=ON -Denable_cplusplus=OFF
cmake ../../../../3rdParty/gc-8.2.12 -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/release -Denable_threads=ON -Denable_cplusplus=OFF
cmake --build . --config Release -j 16
cmake --install . --config Release
2 changes: 1 addition & 1 deletion scripts/build_gc_release_ninja.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pushd
mkdir __build\gc\ninja\release
cd __build\gc\ninja\release
cmake ../../../../3rdParty/gc-8.2.8 -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/release -Denable_threads=ON -Denable_cplusplus=OFF
cmake ../../../../3rdParty/gc-8.2.12 -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=../../../../3rdParty/gc/release -Denable_threads=ON -Denable_cplusplus=OFF
cmake --build . --config Release -j 8
cmake --install . --config Release
popd
2 changes: 1 addition & 1 deletion scripts/build_gc_release_vs.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pushd
mkdir __build\gc\msbuild\x64\release
cd __build\gc\msbuild\x64\release
cmake ../../../../../3rdParty/gc-8.2.8 -G "Visual Studio 18 2026" -A x64 %EXTRA_PARAM% -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX=../../../../../3rdParty/gc/x64/release -Denable_threads=ON -Denable_cplusplus=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake ../../../../../3rdParty/gc-8.2.12 -G "Visual Studio 18 2026" -A x64 %EXTRA_PARAM% -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -Wno-dev -DCMAKE_INSTALL_PREFIX=../../../../../3rdParty/gc/x64/release -Denable_threads=ON -Denable_cplusplus=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build . --config Release -j 8
cmake --install . --config Release
popd
20 changes: 18 additions & 2 deletions tsc/test/tester/test-runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ void createSharedMultiBatchFile(std::string tempOutputFileNameNoExt, std::vector
batFile << "set TSC_LIB_PATH=" << TEST_TSC_LIBPATH << std::endl;
batFile << "set GC_LIB_PATH=" << TEST_GCPATH << std::endl;

// run everything inside a unique per-test working directory: the shared lib must keep its
// real name (<stem>.dll) for `import './<stem>'` to resolve, but that name is not unique
// across tests reusing the same source file (e.g. decl_class.ts feeds the compile/compile-time/jit
// variants) - isolating the cwd avoids parallel collisions under `ctest -j`. The .txt/.err output
// is written to the parent dir where the runner reads it from.
batFile << "set WORKDIR=" << tempOutputFileNameNoExt << "_wd" << std::endl;
batFile << "if exist %WORKDIR% rmdir /s /q %WORKDIR%" << std::endl;
batFile << "mkdir %WORKDIR%" << std::endl;
batFile << "cd %WORKDIR%" << std::endl;

auto first = true;
std::stringstream shared_objs;
std::stringstream shared_libs;
Expand Down Expand Up @@ -472,7 +482,7 @@ void createSharedMultiBatchFile(std::string tempOutputFileNameNoExt, std::vector

if (jitRun)
{
batFile << "%TSCEXEPATH%\\tsc.exe --emit=jit " << tsc_opt << " --shared-libs=%TSCEXEPATH%/TypeScriptRuntime.dll " << *files.begin() << " 1> %FILENAME%.txt 2> %FILENAME%.err"
batFile << "%TSCEXEPATH%\\tsc.exe --emit=jit " << tsc_opt << " --shared-libs=%TSCEXEPATH%/TypeScriptRuntime.dll " << *files.begin() << " 1> ..\\%FILENAME%.txt 2> ..\\%FILENAME%.err"
<< std::endl;

batFile << "del " << shared_libs.str() << std::endl;
Expand All @@ -494,7 +504,7 @@ void createSharedMultiBatchFile(std::string tempOutputFileNameNoExt, std::vector

batFile << "del " << exec_objs.str() << std::endl;

batFile << "call " RUN_CMD "%FILENAME%.exe 1> %FILENAME%.txt 2> %FILENAME%.err" << std::endl;
batFile << "call " RUN_CMD "%FILENAME%.exe 1> ..\\%FILENAME%.txt 2> ..\\%FILENAME%.err" << std::endl;

batFile << "echo off" << std::endl;
batFile << "del " << shared_libs.str() << std::endl;
Expand All @@ -506,6 +516,12 @@ void createSharedMultiBatchFile(std::string tempOutputFileNameNoExt, std::vector
batFile << "echo on" << std::endl;
}

// leave and remove the per-test working directory (with the shared lib, exe, objs, etc.)
batFile << "echo off" << std::endl;
batFile << "cd .." << std::endl;
batFile << "rmdir /s /q %WORKDIR%" << std::endl;
batFile << "echo on" << std::endl;

batFile.close();
#else
std::ofstream batFile(tempOutputFileNameNoExt + BAT_NAME);
Expand Down
28 changes: 13 additions & 15 deletions tsc/tsc/exe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,29 +437,27 @@ int buildExe(int argc, char **argv, std::string objFileName, std::string additio
// system
if (win)
{
args.push_back("-luser32");
args.push_back("-luser32");

// Link the static CRT (/MT[d]) to match the prebuilt static LLVM/MLIR libs,
// the TypeScript runtime libs and gc.lib. Mixing the static and dynamic CRT
// gives the generated program a separate heap/stdout buffer from those libs
// and crashes at startup/teardown (0xC0000005). The release config uses the
// non-debug import-name suffix; debug uses the 'd' suffix.
if (enableOpt)
{
args.push_back("-lucrt");
args.push_back("-llibucrt");
args.push_back("-llibcmt");
args.push_back("-llibvcruntime");
}
else
{
args.push_back("-lucrtd");
args.push_back("-llibucrtd");
args.push_back("-llibcmtd");
args.push_back("-llibvcruntimed");
}

args.push_back("-lntdll");
if (shared || !disableGC)
{
// needed to resolve DLL ref
if (enableOpt)
{
args.push_back("-lmsvcrt");
}
else
{
args.push_back("-lmsvcrtd");
}
}
}

// tsc libs
Expand Down
Loading