Open compiler project in Visual Studio
- Do all steps from Build Argentum from sources on Windows
- In Visual Studio main menu choose
File->Open->CMake
selectD:\cpp\argentum\CMakeLists.txtor where you installed it. - If your directory is not
d:\cpp, openCMakeSettings.json
openx64-Debugconfiguration
and change paths to your directory in the following CMake variables:- SDL2_DIR
- SDL2_image_DIR
- LLVM_DIR
Run/Debug
Select x64-Debug configuration and ag-test.exe as a startup target. Run/debug code as usual.
To run/debug the Argentum compiler (agc):
- Select
agc.exeas a startup target - Open
Debug->Debug and Launch Settings for agcand locate the property:"name": "agc.exe" - Insert another property after it:
, "args": [ "-src", "d:\cpp\argentum\demo", "-start", "helloWorld", "-O3", "-o", "x.obj"]
(Fix the paths if it differs or add your own desired command line args if needed) - Run/debug as usual
Tip: if paste to "args": [] a raw command line (like -src d:\cpp\argentum\demo -start helloWorld -O3 -o x.obj), it will be automatically tokenized, quoted and escaped (not always correctly though).
Build the release compiler version
In contrast to debug versions, the release agc doesn't use MSVC runtime in DLL. And also they have different iterator safety settings in release and debug. That's why release agc should be linked to the release version of the LLVM. So steps are:
Build release LLVM:
cd /d d:\cpp\llvm-project-llvmorg-17.0.4
cmake -S llvm -B build-rel -G "Visual Studio 17 2022" ^
-Thost=x64 -A x64 ^
-DLLVM_USE_CRT_RELEASE=MT ^
-DCMAKE_BUILD_TYPE=RelWithDebInfo ^
-DLLVM_ENABLE_PROJECTS="llvm" ^
-DLLVM_BUILD_RUNTIME=OFF ^
-DLLVM_BUILD_EXAMPLES=OFF ^
-DLLVM_BUILD_TESTS=OFF ^
-DLLVM_BUILD_UTILS=OFF ^
-DLLVM_TARGETS_TO_BUILD=X86 ^
-DCMAKE_INSTALL_PREFIX=D:\cpp\llvm-17.0.4-rel
cmake --build build-rel --target install
Where:
- LLVM_USE_CRT_RELEASE=MT <-- selects non DLL runtime
- CMAKE_BUILD_TYPE=RelWithDebInfo <-- adds debug info
Tip: if you want to experiment with LLVM build flags, use a separate step cmake --build build-rel that builds everything but leaves the output directory D:\cpp\llvm-17.0.4-rel intact.
If your directory is not d:\cpp, update SDL2_DIR, SDL2_image_DIR, LLVM_DIR in x64-Release and x64-RelWithDebInfo configurations of CMakeSettings.json
Select x64-Release configuration and build everything Ctrl+Shift+B.
Build results are located in: D:\cpp\argentum\out\build\x64-Release
