Skip to content

Commit

Permalink
Fix lld-targets + build Ubuntu 18.04/20.04 (#8)
Browse files Browse the repository at this point in the history
* update lld-targets

* try adding distros

* fix yaml

* update patch

* update yaml

* update

* update yaml

* update YAML

* update yaml again

* split 18.04/20.04

* try fixing ubuntu conditional

* try updating cctools

* update cctools

* update cctools

* add initial msvc-bundle workflow

* update stuff

* fix wget

* add linux distro-specific initial cache files

* add xcode-bundle

Co-authored-by: Marc-André Moreau <[email protected]>
  • Loading branch information
awakecoding and Marc-André Moreau authored Sep 9, 2021
1 parent 61830ce commit 6a67104
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 52 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cctools-prebuilt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ jobs:
fail-fast: false
matrix:
arch: [ x86_64 ]
os: [ linux ]
os: [ ubuntu-18.04, ubuntu-20.04 ]

include:
- os: linux
- os: ubuntu-18.04
runner: ubuntu-18.04
- os: ubuntu-20.04
runner: ubuntu-20.04

steps:
- name: Configure Linux runner
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install git xz-utils
sudo apt install git xz-utils ninja-build
sudo apt install libssl-dev libxml2-dev liblzma-dev libbz2-dev
sudo apt install ninja-build ${{matrix.multilib}}
- name: Build libxar
run: |
Expand Down
38 changes: 27 additions & 11 deletions .github/workflows/llvm-prebuilt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: LLVM prebuilt
on: workflow_dispatch
jobs:
build:
name: LLVM ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}]
name: LLVM ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}] ${{matrix.distro}}
runs-on: ${{matrix.runner}}
strategy:
fail-fast: false
matrix:
arch: [ x86_64, aarch64 ]
os: [ windows, macos, linux ]
os: [ windows, macos, ubuntu-18.04, ubuntu-20.04 ]
version: [ 12.0.1 ]

include:
Expand All @@ -19,8 +19,10 @@ jobs:
runner: windows-2019
- os: macos
runner: macos-10.15
- os: linux
- os: ubuntu-18.04
runner: ubuntu-18.04
- os: ubuntu-20.04
runner: ubuntu-20.04

- arch: x86_64
os: windows
Expand All @@ -35,9 +37,6 @@ jobs:
- arch: aarch64
os: macos
osx_arch: arm64

- arch: aarch64
os: linux
steps:
- name: Configure Windows runner
if: runner.os == 'Windows'
Expand All @@ -50,16 +49,33 @@ jobs:
brew install ninja
echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
- name: Configure Ubuntu runner
if: runner.os == 'Linux'
- name: Configure Ubuntu 18.04 runner
if: matrix.os == 'ubuntu-18.04'
shell: pwsh
run: |
sudo apt update
sudo apt install xz-utils libxml2-dev
sudo apt install ninja-build
sudo apt install g++-aarch64-linux-gnu
mkdir libxml2-dev-arm64 && cd libxml2-dev-arm64
$LibXmlDebFile = "libxml2-dev_2.9.4+dfsg1-6.1ubuntu1.4_arm64.deb"
wget -q "http://ports.ubuntu.com/pool/main/libx/libxml2/$LibXmlDebFile"
ar -x "$LibXmlDebFile"
tar -xf data.tar.xz
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu
- name: Configure Ubuntu 20.04 runner
if: matrix.os == 'ubuntu-20.04'
shell: pwsh
run: |
sudo apt update
sudo apt install xz-utils libxml2-dev
sudo apt install ninja-build
sudo apt install g++-aarch64-linux-gnu
mkdir libxml2-dev-arm64 && cd libxml2-dev-arm64
wget http://ports.ubuntu.com/pool/main/libx/libxml2/libxml2-dev_2.9.4+dfsg1-6.1ubuntu1.4_arm64.deb
ar -x libxml2-dev_2.9.4+dfsg1-6.1ubuntu1.4_arm64.deb
$LibXmlDebFile = "libxml2-dev_2.9.10+dfsg-5ubuntu0.20.04.1_arm64.deb"
wget -q "http://ports.ubuntu.com/pool/main/libx/libxml2/$LibXmlDebFile"
ar -x "$LibXmlDebFile"
tar -xf data.tar.xz
sudo cp -R ./usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu
Expand All @@ -77,7 +93,7 @@ jobs:

- name: Patch LLVM
run: |
git -C llvm-project apply ../llvm-prebuilt/patches/0001-add-lld-headers-target.patch
git -C llvm-project apply ../llvm-prebuilt/patches/0001-add-lld-install-targets.patch
- name: Enable Windows host environment
if: runner.os == 'Windows'
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/msvc-bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: msvc bundle
on: workflow_dispatch
jobs:
build:
name: MSVC bundle
runs-on: windows-2019
steps:
- name: Configure Windows runner
run: |
choco install 7zip
- name: Enable Windows target environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64

- name: Copy MSVC bundle
shell: pwsh
run: |
$BundlePath = $Env:GITHUB_WORKSPACE
Copy-Item -Recurse -Path $Env:VCToolsInstallDir\include -Destination $BundlePath\vctools\include
Copy-Item -Recurse -Path $Env:VCToolsInstallDir\lib -Destination $BundlePath\vctools\lib
Copy-Item -Recurse -Path $Env:WindowsSdkDir\Include\$Env:WindowsSDKVersion\ $BundlePath\winsdk\Include\$Env:WindowsSDKVersion
Copy-Item -Recurse -Path $Env:WindowsSdkDir\Lib\$Env:WindowsSDKVersion\ $BundlePath\winsdk\Lib\$Env:WindowsSDKVersion
- name: Package MSVC bundle
shell: pwsh
run: |
cmd.exe /c "7z a -ttar -snl -so vctools.tar vctools | 7z a -si vctools.tar.xz"
cmd.exe /c "7z a -ttar -snl -so winsdk.tar winsdk | 7z a -si winsdk.tar.xz"
- name: Upload vctools package
uses: actions/upload-artifact@v2
with:
name: vctools
path: vctools.tar.xz

- name: Upload winsdk package
uses: actions/upload-artifact@v2
with:
name: winsdk
path: winsdk.tar.xz
45 changes: 45 additions & 0 deletions .github/workflows/xcode-bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: xcode bundle
on: workflow_dispatch
jobs:
build:
name: Xcode bundle
runs-on: macos-10.15
steps:
- name: Configure macOS runner
run: |
brew install --cask powershell
- name: Copy Xcode bundle
shell: pwsh
run: |
$XcodeDeveloperPath = $(xcode-select -p)
$XcodePlatformsPath = Join-Path $XcodeDeveloperPath "Platforms"
$BundlePath = Join-Path $Env:GITHUB_WORKSPACE "xcode-bundle"
New-Item -Path $BundlePath -ItemType Directory | Out-Null
foreach ($Platform in @('MacOSX','iPhoneOS','iPhoneSimulator')) {
Write-Host "Copying $Platform SDK"
$PlatformPath = Join-Path $XcodePlatformsPath "$Platform.platform"
$PlatformSdkPath = Join-Path $PlatformPath "Developer" "SDKs" "$Platform.sdk"
Copy-Item -Recurse -Path $PlatformSdkPath -Destination $BundlePath
}
Write-Host "Copying Xcode xctoolchain"
$XcodeToolchainsPath = Join-Path $XcodeDeveloperPath "Toolchains"
$XcodeToolchainPath = Join-Path $XcodeToolchainsPath "XcodeDefault.xctoolchain"
$DestinationPath = Join-Path $BundlePath "XcodeDefault.xctoolchain"
New-Item -Path $DestinationPath -ItemType Directory | Out-Null
Copy-Item -Recurse -Path "$XcodeToolchainPath\usr\include" -Destination "$DestinationPath\usr\include"
Copy-Item -Recurse -Path "$XcodeToolchainPath\usr\lib" -Destination "$DestinationPath\usr\lib"
- name: Package Xcode bundle
shell: pwsh
run: |
tar -cJf xcode-bundle.tar.xz xcode-bundle
- name: Upload xcode-bundle package
uses: actions/upload-artifact@v2
with:
name: xcode-bundle
path: xcode-bundle.tar.xz
1 change: 1 addition & 0 deletions cmake/aarch64-ubuntu-18.04.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/aarch64-linux.cmake")
1 change: 1 addition & 0 deletions cmake/aarch64-ubuntu-20.04.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/aarch64-linux.cmake")
1 change: 1 addition & 0 deletions cmake/llvm-distribution.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ set(LLVM_DEVELOPMENT_COMPONENTS
clang-resource-headers
libclang-headers
lld-headers # requires patch
lld-libraries # requires patch
lld-cmake-exports
CACHE STRING "")

Expand Down
1 change: 1 addition & 0 deletions cmake/x86_64-ubuntu-18.04.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/x86_64-linux.cmake")
1 change: 1 addition & 0 deletions cmake/x86_64-ubuntu-20.04.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/x86_64-linux.cmake")
36 changes: 0 additions & 36 deletions patches/0001-add-lld-headers-target.patch

This file was deleted.

77 changes: 77 additions & 0 deletions patches/0001-add-lld-install-targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From 2b6f6d9199b1a7ce9e9034df3909cddd8bcde6d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <[email protected]>
Date: Wed, 8 Sep 2021 08:49:13 -0400
Subject: [PATCH] add lld install targets

---
lld/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++
lld/cmake/modules/AddLLD.cmake | 2 +-
2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 2e99564f4..5bb3d9ec0 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -189,9 +189,19 @@ include_directories(BEFORE
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
DESTINATION include
+ COMPONENT lld-headers
FILES_MATCHING
PATTERN "*.h"
)
+
+ add_custom_target(lld-headers)
+ set_target_properties(lld-headers PROPERTIES FOLDER "Misc")
+
+ if(NOT LLVM_ENABLE_IDE)
+ add_llvm_install_targets(install-lld-headers
+ DEPENDS lld-headers
+ COMPONENT lld-headers)
+ endif()
endif()

add_subdirectory(Common)
@@ -210,4 +220,26 @@ add_subdirectory(MachO)
add_subdirectory(MinGW)
add_subdirectory(wasm)

+# Custom target to install all lld libraries.
+add_custom_target(lld-libraries)
+set_target_properties(lld-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT LLVM_ENABLE_IDE)
+ add_llvm_install_targets(install-lld-libraries
+ DEPENDS lld-libraries
+ COMPONENT lld-libraries)
+endif()
+
+get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
+if(LLD_EXPORTS)
+ list(REMOVE_DUPLICATES LLD_EXPORTS)
+ foreach(lib ${LLD_EXPORTS})
+ add_dependencies(lld-libraries ${lib})
+ if(NOT LLVM_ENABLE_IDE)
+ add_dependencies(install-lld-libraries install-${lib})
+ add_dependencies(install-lld-libraries-stripped install-${lib}-stripped)
+ endif()
+ endforeach()
+endif()
+
add_subdirectory(cmake/modules)
diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake
index 9883475d1..b2f597191 100644
--- a/lld/cmake/modules/AddLLD.cmake
+++ b/lld/cmake/modules/AddLLD.cmake
@@ -21,7 +21,7 @@ macro(add_lld_library name)
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
RUNTIME DESTINATION bin)

- if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+ if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
--
2.25.1

0 comments on commit 6a67104

Please sign in to comment.