Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipe for the LLVM SPIR-V back-end. #10516

Merged
merged 4 commits into from
Feb 13, 2025
Merged

Conversation

maleadt
Copy link
Contributor

@maleadt maleadt commented Feb 12, 2025

To check if it's possible to move from https://github.com/KhronosGroup/SPIRV-LLVM-Translator to LLVM proper.

Doesn't need platform augmentations, because I'd like to simply use the latest version of the back-end possible. This works as long as we statically link libLLVM, but may still pose problems when there's IR incompatibilities that can't get auto-upgraded.

cc @vchuravy

@maleadt maleadt enabled auto-merge (squash) February 12, 2025 12:29
@maleadt maleadt disabled auto-merge February 12, 2025 12:29
@maleadt maleadt force-pushed the tb/spirv_llvm_backend branch from 789799a to d4643bd Compare February 12, 2025 12:30
@giordano
Copy link
Member

using BinaryBuilder, Pkg

name = "SPIRV_LLVM_Backend"
version = v"19"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only loosely following LLVM's versioning here so that we can still make minor releases ourselves (e.g. containing Julia-specific patches).

@maleadt
Copy link
Contributor Author

maleadt commented Feb 12, 2025

You want to delete https://github.com/JuliaBinaryWrappers/SPIRV_LLVM_Backend_jll.jl/releases/tag/SPIRV_LLVM_Backend-v0.1.0%2B0 otherwise registration will fail

Ah, good call. I accidentally deployed that by doing --deploy maleadt/SPIRV_LLVM_Backend_jll.jl, omitting the =...

I've just deleted the entire repo.

@maleadt
Copy link
Contributor Author

maleadt commented Feb 12, 2025

Turns out the back-end from LLVM 19 is pretty unusable, so I'll bump this to 20 straight away (sorry for wasting some compute time here).

@maleadt
Copy link
Contributor Author

maleadt commented Feb 12, 2025

ld64.lld: error: undefined symbol: __isPlatformVersionAtLeast

LLVM 20 failing to build?

@giordano
Copy link
Member

elif [[ "${target}" == aarch64-apple-* ]]; then
# Link to libclang_rt.osx to resolve the symbol `___isPlatformVersionAtLeast`:
# <https://github.com/libsdl-org/SDL/issues/6491>.
export LDFLAGS="-L${libdir}/darwin -lclang_rt.osx"
fi

@giordano
Copy link
Member

giordano commented Feb 12, 2025

For LLVM specifically, others have simply patched out the offending file:

diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index 27c8a1bc9b7..11f2cc518d0 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -1201,7 +1201,7 @@ namespace fs {
std::error_code copy_file(const Twine &From, const Twine &To) {
uint32_t Flag = COPYFILE_DATA;
#if __has_builtin(__builtin_available) && defined(COPYFILE_CLONE)
- if (__builtin_available(macos 10.12, *)) {
+ {
bool IsSymlink;
if (std::error_code Error = is_symlink_file(From, IsSymlink))
return Error;

https://github.com/llvm/llvm-project/blob/ff8f6abe20a9dfbb1de8d978f865092413d3416c/llvm/lib/Support/Unix/Path.inc#L1490

@maleadt maleadt merged commit 117874b into master Feb 13, 2025
21 checks passed
@maleadt maleadt deleted the tb/spirv_llvm_backend branch February 13, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants