Skip to content

Commit

Permalink
Merge pull request #9 from polac24/bartosz/20230403-llvm-16
Browse files Browse the repository at this point in the history
Bump to LLVM16
  • Loading branch information
polac24 authored Apr 4, 2023
2 parents 58636f5 + 0e6c664 commit f7a35ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/Release/dia-merge.zip
asset_name: dia-merge-x86_64.zip
asset_name: dia-merge-arm64.zip
tag: ${{ github.ref }}
overwrite: true
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ find_package(Curses REQUIRED)
function(add_dia_executable execname)
add_executable("${execname}" "${execname}.cpp")
target_include_directories("${execname}" PRIVATE ${LLVM_DIR}/include)
target_compile_features("${execname}" PUBLIC cxx_std_14)
target_compile_features("${execname}" PUBLIC cxx_std_17)
set_target_properties("${execname}" PROPERTIES CXX_EXTENSIONS OFF)
target_compile_options("${execname}" PRIVATE -Wall -Wextra -fblocks -Wno-unused-parameter)
if(NOT LLVM_ENABLE_RTTI)
target_compile_options("${execname}" PRIVATE -fno-rtti)
endif()
target_link_libraries("${execname}" PUBLIC ${LLVM_DIR}/lib/libclangFrontend.a ${LLVM_DIR}/lib/libclangEdit.a ${LLVM_DIR}/lib/libclangLex.a ${LLVM_DIR}/lib/libclangBasic.a ${LLVM_DIR}/lib/libLLVMBitstreamReader.a ${LLVM_DIR}/lib/libLLVMSupport.a ${CURSES_LIBRARIES}
target_link_libraries("${execname}" PUBLIC ${LLVM_DIR}/lib/libclangFrontend.a ${LLVM_DIR}/lib/libclangEdit.a ${LLVM_DIR}/lib/libclangLex.a ${LLVM_DIR}/lib/libclangBasic.a ${LLVM_DIR}/lib/libLLVMBitstreamReader.a ${LLVM_DIR}/lib/libLLVMSupport.a ${LLVM_DIR}/lib/libLLVMTargetParser.a ${CURSES_LIBRARIES}
)
target_link_options("${execname}" PRIVATE -dead_strip)
endfunction()
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ _Note: There is a limit of the `.dia` file that this mode guarantees consistency

### DIA file

DIA file is a bitcode formatted file that can be inspected with LLVM's bc-analyzer tool.
DIA file is a bitcode formatted file that can be inspected with LLVM's bc-analyzer tool.

## Example

If a project has source root `/source_root/`, on a producer side call:


```
dia-merge -r `^/source_root/=./` -output /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/Example.dia /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/AppDelegate.dia /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/ViewController.dia
dia-merge -r `^/source_root/=./` -output /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/Example.dia /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/AppDelegate.dia /SomeDerivedData/Example/Build/Intermediates.noindex/Example.build/Debug-iphonesimulator/Example.build/Objects-normal/arm64/ViewController.dia
```

On a consumer side, where a source root is `/other_source_root/`, call:
Expand All @@ -56,12 +56,12 @@ dia-merge -r `^\./=/other_source_root/` -output build_system/ExpectedLocation.di
## Build Instructions

To build, first download LLVM prebuilt binary from https://github.com/llvm/llvm-project/releases, e.g. https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz
So far, LLVM publishes only x86_64 architecture, so on arm64 machines, rosetta2 emulation is needed.
LLVM publishes only arm64 architecture, so on x86_64 machines, you may need to built it locally.

```sh
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DLLVM_DIR=#{path_to_downloaded_clang} ..
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DLLVM_DIR=#{path_to_downloaded_clang} ..
ninja
```

Expand All @@ -70,7 +70,7 @@ See [RELEASING.md](RELEASING.md) for a fat-architecture.
Or, if you prefer Xcode for building and debugging, you can replace the last 2 lines with the following:

```
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DLLVM_DIR=#{path_to_downloaded_clang} ..
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DLLVM_DIR=#{path_to_downloaded_clang} ..
open dia-merge.xcodeproj
```

Expand All @@ -84,7 +84,7 @@ cd build
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-apple-darwin.tar.xz" --output clang.zip
mkdir -p clang-downloaded
tar -xvf ./clang.zip -C clang-downloaded --strip 1
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DLLVM_DIR="$PWD/clang-downloaded" ..
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DLLVM_DIR="$PWD/clang-downloaded" ..
open dia-merge.xcodeproj
```

Expand All @@ -104,4 +104,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
```
7 changes: 4 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#/!bin/bash


: ${CLANG_VERSION:=15.0.0}
: ${CLANG_VERSION:=16.0.0}
: ${DIST_SUFFIX:=arm64-apple-darwin22.0}

LLVM_PACKAGE_PATH="$PWD/llvm.tar.gz"
LLVM_UNZIPPED_PACKAGE_PATH="$PWD/llvm"
Expand All @@ -11,7 +12,7 @@ LLVM_UNZIPPED_PACKAGE_PATH="$PWD/llvm"


# -L to follow redirects
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/clang+llvm-${CLANG_VERSION}-x86_64-apple-darwin.tar.xz" --output "$LLVM_PACKAGE_PATH"
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/clang+llvm-${CLANG_VERSION}-${DIST_SUFFIX}.tar.xz" --output "$LLVM_PACKAGE_PATH"

mkdir -p "$LLVM_UNZIPPED_PACKAGE_PATH"
# --strip 1 to not include a wrapped dir and extract directly to $LLVM_UNZIPPED_PACKAGE_PATH
Expand All @@ -21,7 +22,7 @@ tar -xvf "$LLVM_PACKAGE_PATH" -C "$LLVM_UNZIPPED_PACKAGE_PATH" --strip 1
# TODO: Using Xcode for now, as CI doesn't have ninja
mkdir -p build
pushd build
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DLLVM_DIR="$LLVM_UNZIPPED_PACKAGE_PATH" ..
cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DLLVM_DIR="$LLVM_UNZIPPED_PACKAGE_PATH" ..

### Build a project
xcodebuild -configuration Release
Expand Down

0 comments on commit f7a35ba

Please sign in to comment.