Skip to content

Commit

Permalink
Prepare compiler-rt build by trying to build Clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Jul 15, 2024
1 parent 038ccdf commit a15f5fc
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 11 deletions.
27 changes: 27 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
%WORKING_DRIVE%
cd %WORKING_DIR%

::..............................................................................

set THIS_DIR=%CD%

if /i "%BUILD_PROJECT%" == "llvm" goto :llvm
if /i "%BUILD_PROJECT%" == "compiler-rt" goto :compilerrt

echo Invalid argument: '%1'
exit -1

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:llvm

cd llvm-project

mkdir llvm\build
Expand All @@ -19,3 +31,18 @@ cd %THIS_DIR%

goto :eof

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

:compilerrt

mkdir clang\build
cd clang\build
cmake .. %CLANG_CMAKE_CONFIGURE_FLAGS%
cmake --build . %CMAKE_BUILD_FLAGS%
cmake --build . --target install %CMAKE_BUILD_FLAGS%

cd %THIS_DIR%

7z a -t7z %GITHUB_WORKSPACE%\%CLANG_RELEASE_FILE% %CLANG_RELEASE_NAME%

goto :eof
37 changes: 36 additions & 1 deletion install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if not exist %WORKING_DIR% mkdir %WORKING_DIR%
::..............................................................................

if /i "%BUILD_PROJECT%" == "llvm" goto :llvm
if /i "%BUILD_PROJECT%" == "clang" goto :clang
if /i "%BUILD_PROJECT%" == "compiler-rt" goto :compilerrt

echo Invalid argument: '%1'
exit -1
Expand Down Expand Up @@ -45,3 +45,38 @@ perl pdb-patch.pl %WORKING_DIR%\llvm-project\llvm\cmake\modules\AddLLVM.cmake

goto :eof

::..............................................................................

:compilerrt

:: download Clang sources

if /i "%BUILD_MASTER%" == "true" (
git clone --depth=1 %LLVM_MASTER_URL% %WORKING_DIR%\llvm-git
move %WORKING_DIR%\llvm-git\clang %WORKING_DIR%
if exist %WORKING_DIR%\llvm-git\cmake move %WORKING_DIR%\llvm-git\cmake %WORKING_DIR%
) else (
powershell "Invoke-WebRequest -Uri %CLANG_DOWNLOAD_URL% -OutFile %WORKING_DIR%\%CLANG_DOWNLOAD_FILE%"
7z x -y %WORKING_DIR%\%CLANG_DOWNLOAD_FILE% -o%WORKING_DIR%
7z x -y %WORKING_DIR%\%CLANG_DOWNLOAD_FILE_PREFIX%%LLVM_VERSION%.src.tar -o%WORKING_DIR%
ren %WORKING_DIR%\%CLANG_DOWNLOAD_FILE_PREFIX%%LLVM_VERSION%.src clang

if not "%LLVM_CMAKE_DOWNLOAD_URL%" == "" (
powershell "Invoke-WebRequest -Uri %LLVM_CMAKE_DOWNLOAD_URL% -OutFile %WORKING_DIR%\%LLVM_CMAKE_DOWNLOAD_FILE%"
7z x -y %WORKING_DIR%\%LLVM_CMAKE_DOWNLOAD_FILE% -o%WORKING_DIR%
7z x -y %WORKING_DIR%\cmake-%LLVM_VERSION%.src.tar -o%WORKING_DIR%
ren %WORKING_DIR%\cmake-%LLVM_VERSION%.src cmake
)
)

:nobigobj

:: download and unpack LLVM release package from llvm-package-windows

powershell "Invoke-WebRequest -Uri %LLVM_RELEASE_URL% -OutFile %WORKING_DIR%\%LLVM_RELEASE_FILE%"
7z x -y %WORKING_DIR%\%LLVM_RELEASE_FILE% -o%WORKING_DIR%
;;

goto :eof

::..............................................................................
49 changes: 39 additions & 10 deletions set-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ exit -1

:x86
set TARGET_CPU=x86
set CMAKE_GENERATOR_SUFFIX=
set CMAKE_GENERATOR_SUFFIX= x86
set CMAKE_ARCH_OPTIONS=-A Win32
shift
goto :loop

:amd64
set TARGET_CPU=amd64
set CMAKE_GENERATOR_SUFFIX=
set CMAKE_ARCH_OPTIONS=-A x64
shift
goto :loop

Expand Down Expand Up @@ -159,7 +161,6 @@ set BASE_DOWNLOAD_URL=https://github.com/llvm/llvm-project/releases/download/llv
set LLVM_MASTER_URL=https://github.com/llvm/llvm-project
set LLVM_DOWNLOAD_FILE=llvm-project-%LLVM_VERSION%.src%TAR_SUFFIX%
set LLVM_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%LLVM_DOWNLOAD_FILE%

set LLVM_RELEASE_NAME=llvm-%LLVM_VERSION%-windows-%TARGET_CPU%-%TOOLCHAIN%-%CRT%%DEBUG_SUFFIX%
set LLVM_RELEASE_FILE=%LLVM_RELEASE_NAME%.7z
set LLVM_RELEASE_DIR=%WORKING_DIR%\%LLVM_RELEASE_NAME%
Expand Down Expand Up @@ -188,6 +189,29 @@ set LLVM_CMAKE_CONFIGURE_FLAGS= ^

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

set CLANG_MASTER_URL=https://github.com/llvm-mirror/clang
set CLANG_DOWNLOAD_FILE=%CLANG_DOWNLOAD_FILE_PREFIX%%LLVM_VERSION%.src%TAR_SUFFIX%
set CLANG_DOWNLOAD_URL=%BASE_DOWNLOAD_URL%/%CLANG_DOWNLOAD_FILE%
set CLANG_RELEASE_NAME=clang-%LLVM_VERSION%-windows-%TARGET_CPU%-%TOOLCHAIN%-%CRT%%DEBUG_SUFFIX%
set CLANG_RELEASE_FILE=%CLANG_RELEASE_NAME%.7z
set CLANG_RELEASE_DIR=%WORKING_DIR%\%CLANG_RELEASE_NAME%
set CLANG_RELEASE_DIR=%CLANG_RELEASE_DIR:\=/%

set CLANG_CMAKE_CONFIGURE_FLAGS= ^
-G "%CMAKE_GENERATOR%" ^
%CMAKE_OPTIONS% ^
-DCMAKE_INSTALL_PREFIX=%CLANG_RELEASE_DIR% ^
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=TRUE ^
-DLLVM_INCLUDE_TESTS=OFF ^
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON ^
-DCLANG_INCLUDE_DOCS=OFF ^
-DCLANG_INCLUDE_TESTS=OFF ^
-DLLVM_DIR=%LLVM_RELEASE_DIR%/lib/cmake/llvm ^
%LLVM_CMAKE_CRT_FLAGS% ^
%CLANG_CMAKE_CONFIGURE_EXTRA_FLAGS%

:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

set CMAKE_BUILD_FLAGS= ^
--config %CONFIGURATION% ^
-- ^
Expand All @@ -196,15 +220,20 @@ set CMAKE_BUILD_FLAGS= ^
/maxcpucount ^
/consoleloggerparameters:Summary

set DEPLOY_FILE=%LLVM_RELEASE_FILE%
if /i "%BUILD_PROJECT%" == "llvm" set DEPLOY_FILE=%LLVM_RELEASE_FILE%
if /i "%BUILD_PROJECT%" == "compiler-rt" set DEPLOY_FILE=%CLANG_RELEASE_FILE%

echo ---------------------------------------------------------------------------
echo LLVM_VERSION: %LLVM_VERSION%
echo LLVM_MASTER_URL: %LLVM_MASTER_URL%
echo LLVM_DOWNLOAD_URL: %LLVM_DOWNLOAD_URL%
echo LLVM_RELEASE_FILE: %LLVM_RELEASE_FILE%
echo LLVM_RELEASE_URL: %LLVM_RELEASE_URL%
echo LLVM_CMAKE_CONFIGURE_FLAGS: %LLVM_CMAKE_CONFIGURE_FLAGS%
echo LLVM_VERSION: %LLVM_VERSION%
echo LLVM_MASTER_URL: %LLVM_MASTER_URL%
echo LLVM_DOWNLOAD_URL: %LLVM_DOWNLOAD_URL%
echo LLVM_RELEASE_FILE: %LLVM_RELEASE_FILE%
echo LLVM_RELEASE_URL: %LLVM_RELEASE_URL%
echo LLVM_CMAKE_CONFIGURE_FLAGS: %LLVM_CMAKE_CONFIGURE_FLAGS%
echo ---------------------------------------------------------------------------
echo DEPLOY_FILE: %DEPLOY_FILE%
echo CLANG_DOWNLOAD_URL: %CLANG_DOWNLOAD_URL%
echo CLANG_RELEASE_FILE: %CLANG_RELEASE_FILE%
echo CLANG_CMAKE_CONFIGURE_FLAGS: %CLANG_CMAKE_CONFIGURE_FLAGS%
echo ---------------------------------------------------------------------------
echo DEPLOY_FILE: %DEPLOY_FILE%
echo ---------------------------------------------------------------------------

0 comments on commit a15f5fc

Please sign in to comment.