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

Rebolt LLVM #4073

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/l/llvm-bolt/abi_used_symbols
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ libc.so.6:__ctype_tolower_loc
libc.so.6:__ctype_toupper_loc
libc.so.6:__cxa_atexit
libc.so.6:__errno_location
libc.so.6:__getcwd_chk
libc.so.6:__isoc23_strtol
libc.so.6:__isoc23_strtoll
libc.so.6:__isoc23_strtoull
libc.so.6:__libc_single_threaded
libc.so.6:__libc_start_main
libc.so.6:__memcpy_chk
libc.so.6:__readlink_chk
libc.so.6:__realpath_chk
libc.so.6:__sched_cpucount
libc.so.6:__snprintf_chk
libc.so.6:__stack_chk_fail
libc.so.6:__vprintf_chk
libc.so.6:__vsnprintf_chk
libc.so.6:_exit
libc.so.6:abort
libc.so.6:access
Expand Down Expand Up @@ -77,7 +81,6 @@ libc.so.6:posix_spawn_file_actions_addopen
libc.so.6:posix_spawn_file_actions_destroy
libc.so.6:posix_spawn_file_actions_init
libc.so.6:pread
libc.so.6:printf
libc.so.6:pthread_attr_destroy
libc.so.6:pthread_attr_init
libc.so.6:pthread_attr_setstacksize
Expand All @@ -92,13 +95,11 @@ libc.so.6:pthread_rwlock_wrlock
libc.so.6:pthread_self
libc.so.6:pthread_setname_np
libc.so.6:pthread_sigmask
libc.so.6:putchar
libc.so.6:qsort
libc.so.6:raise
libc.so.6:rand
libc.so.6:read
libc.so.6:readdir
libc.so.6:readlink
libc.so.6:realloc
libc.so.6:realpath
libc.so.6:remove
Expand All @@ -109,7 +110,6 @@ libc.so.6:sigaltstack
libc.so.6:sigemptyset
libc.so.6:sigfillset
libc.so.6:sigprocmask
libc.so.6:snprintf
libc.so.6:srand
libc.so.6:stat
libc.so.6:statfs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From d36e304cc0a0b12e61437c2062314595b8246eee Mon Sep 17 00:00:00 2001
From: Joey Riches <josephriches@gmail.com>
Date: Tue, 15 Oct 2024 23:41:01 +0100
Subject: [PATCH 1/1] Partial Revert of "[BOLT] Fix .relr section addend
patching"

0053cb8ef0a13b444bea598159f873fade200367

something is bork on x86
---
bolt/lib/Rewrite/RewriteInstance.cpp | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 32ec7abe8b66..f7f63b2ea956 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -5068,11 +5068,9 @@ void RewriteInstance::patchELFAllocatableRelrSection(
const uint8_t PSize = BC->AsmInfo->getCodePointerSize();
const uint64_t MaxDelta = ((CHAR_BIT * DynamicRelrEntrySize) - 1) * PSize;

- auto FixAddend = [&](const BinarySection &Section, const Relocation &Rel,
- uint64_t FileOffset) {
+ auto FixAddend = [&](const BinarySection &Section, const Relocation &Rel) {
// Fix relocation symbol value in place if no static relocation found
- // on the same address. We won't check the BF relocations here since it
- // is rare case and no optimization is required.
+ // on the same address
if (Section.getRelocationAt(Rel.Offset))
return;

@@ -5081,6 +5079,10 @@ void RewriteInstance::patchELFAllocatableRelrSection(
if (!Addend)
return;

+ uint64_t FileOffset = Section.getOutputFileOffset();
+ if (!FileOffset)
+ FileOffset = Section.getInputFileOffset();
+ FileOffset += Rel.Offset;
OS.pwrite(reinterpret_cast<const char *>(&Addend), PSize, FileOffset);
};

@@ -5102,7 +5104,7 @@ void RewriteInstance::patchELFAllocatableRelrSection(
RelOffset = RelOffset == 0 ? SectionAddress + Rel.Offset : RelOffset;
assert((RelOffset & 1) == 0 && "Wrong relocation offset");
RelOffsets.emplace(RelOffset);
- FixAddend(Section, Rel, RelOffset);
+ FixAddend(Section, Rel);
}
}

--
2.47.0

5 changes: 3 additions & 2 deletions packages/l/llvm-bolt/package.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name : llvm-bolt
version : 18.1.8
release : 6
release : 7
source :
- https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/llvm-project-18.1.8.src.tar.xz : 0b58557a6d32ceee97c8d533a59b9212d87e0fc4d2833924eb6c611247db2f2a
homepage : https://github.com/llvm/llvm-project/blob/main/bolt/README.md
license : Apache-2.0
component : programming.tools
summary : Binary Optimization and Layout Tool.
description: |-
description: |
BOLT is a post-link optimizer developed to speed up large applications. It achieves the improvements by optimizing application's code layout based on execution profile gathered by sampling profiler, such as Linux perf tool.
patterns :
- /usr/lib/libbolt_rt*.a
clang : yes
builddeps :
- git
setup : |
%patch -p1 -i $pkgfiles/0001-Partial-Revert-of-BOLT-Fix-.relr-section-addend-patc.patch
%cmake_ninja -S llvm \
-DLLVM_INSTALL_UTILS=ON \
-DBUILD_SHARED_LIBS:BOOL=OFF \
Expand Down
18 changes: 10 additions & 8 deletions packages/l/llvm-bolt/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
<Name>llvm-bolt</Name>
<Homepage>https://github.com/llvm/llvm-project/blob/main/bolt/README.md</Homepage>
<Packager>
<Name>Reilly Brogan</Name>
<Email>solus@reillybrogan.com</Email>
<Name>Joey Riches</Name>
<Email>josephriches@gmail.com</Email>
</Packager>
<License>Apache-2.0</License>
<PartOf>programming.tools</PartOf>
<Summary xml:lang="en">Binary Optimization and Layout Tool.</Summary>
<Description xml:lang="en">BOLT is a post-link optimizer developed to speed up large applications. It achieves the improvements by optimizing application&apos;s code layout based on execution profile gathered by sampling profiler, such as Linux perf tool.</Description>
<Description xml:lang="en">BOLT is a post-link optimizer developed to speed up large applications. It achieves the improvements by optimizing application&apos;s code layout based on execution profile gathered by sampling profiler, such as Linux perf tool.
</Description>
<Archive type="binary" sha1sum="79eb0752a961b8e0d15c77d298c97498fbc89c5a">https://sources.getsol.us/README.Solus</Archive>
</Source>
<Package>
<Name>llvm-bolt</Name>
<Summary xml:lang="en">Binary Optimization and Layout Tool.</Summary>
<Description xml:lang="en">BOLT is a post-link optimizer developed to speed up large applications. It achieves the improvements by optimizing application&apos;s code layout based on execution profile gathered by sampling profiler, such as Linux perf tool.</Description>
<Description xml:lang="en">BOLT is a post-link optimizer developed to speed up large applications. It achieves the improvements by optimizing application&apos;s code layout based on execution profile gathered by sampling profiler, such as Linux perf tool.
</Description>
<PartOf>programming.tools</PartOf>
<Files>
<Path fileType="executable">/usr/bin/llvm-bolt</Path>
Expand All @@ -28,12 +30,12 @@
</Files>
</Package>
<History>
<Update release="6">
<Date>2024-07-03</Date>
<Update release="7">
<Date>2024-10-15</Date>
<Version>18.1.8</Version>
<Comment>Packaging update</Comment>
<Name>Reilly Brogan</Name>
<Email>solus@reillybrogan.com</Email>
<Name>Joey Riches</Name>
<Email>josephriches@gmail.com</Email>
</Update>
</History>
</PISI>
44 changes: 22 additions & 22 deletions packages/l/llvm/package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name : llvm

Check notice on line 1 in packages/l/llvm/package.yml

View workflow job for this annotation

GitHub Actions / Checks

This package is included in the ISO. Consider validating the functionality in a newly built ISO.
version : 18.1.8
release : 120
release : 121
source :
- https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/llvm-project-18.1.8.src.tar.xz : 0b58557a6d32ceee97c8d533a59b9212d87e0fc4d2833924eb6c611247db2f2a
homepage : http://llvm.org/
Expand Down Expand Up @@ -336,29 +336,29 @@

### BOLT
# Instrument
#bolt_instr $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
#bolt_instr $workdir/solusBuildDir/lib64/libLLVM.so.18.1
%bolt_instr $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
%bolt_instr $workdir/solusBuildDir/lib64/libLLVM.so.18.1
# Profile
# cmake -G Ninja -B bolt-profile -S runtimes \
# ${CMAKE_COMMON_OPTIONS} \
# ${CMAKE_X84_64_OPTIONS} \
# -DCMAKE_AR=$workdir/solusBuildDir/bin/llvm-ar \
# -DCMAKE_NM=$workdir/solusBuildDir/bin/llvm-nm \
# -DCMAKE_RANLIB=$workdir/solusBuildDir/bin/llvm-ranlib \
# -DCMAKE_C_COMPILER=$workdir/solusBuildDir/bin/clang \
# -DCMAKE_CXX_COMPILER=$workdir/solusBuildDir/bin/clang++ \
# -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi' \
# -DCMAKE_C_FLAGS_RELEASE="$_LLVM_FLAGS_FINAL" \
# -DCMAKE_CXX_FLAGS_RELEASE="$_LLVM_FLAGS_FINAL"
# ninja %JOBS% -C bolt-profile -v
cmake -G Ninja -B bolt-profile -S runtimes \
${CMAKE_COMMON_OPTIONS} \
${CMAKE_X84_64_OPTIONS} \
-DCMAKE_AR=$workdir/solusBuildDir/bin/llvm-ar \
-DCMAKE_NM=$workdir/solusBuildDir/bin/llvm-nm \
-DCMAKE_RANLIB=$workdir/solusBuildDir/bin/llvm-ranlib \
-DCMAKE_C_COMPILER=$workdir/solusBuildDir/bin/clang \
-DCMAKE_CXX_COMPILER=$workdir/solusBuildDir/bin/clang++ \
-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi' \
-DCMAKE_C_FLAGS_RELEASE="$_LLVM_FLAGS_FINAL" \
-DCMAKE_CXX_FLAGS_RELEASE="$_LLVM_FLAGS_FINAL"
ninja %JOBS% -C bolt-profile -v
# Merge and optimize
#bolt_merge $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
#bolt_merge $workdir/solusBuildDir/lib64/libLLVM.so.18.1
#bolt_opt $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
#bolt_opt $workdir/solusBuildDir/lib64/libLLVM.so.18.1
# Install BOLT'd libs over the LTO build
#install -Dm00777 $workdir/solusBuildDir/lib64/libLLVM.so.18.1 $installdir/usr/lib64/libLLVM.so.18.1
#install -Dm00755 $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1 $installdir/usr/lib64/libclang-cpp.so.18.1
%bolt_merge $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
%bolt_merge $workdir/solusBuildDir/lib64/libLLVM.so.18.1
%bolt_opt $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1
%bolt_opt $workdir/solusBuildDir/lib64/libLLVM.so.18.1
# Install BOLT'd libs
install -Dm00777 $workdir/solusBuildDir/lib64/libLLVM.so.18.1 $installdir/usr/lib64/libLLVM.so.18.1
install -Dm00755 $workdir/solusBuildDir/lib64/libclang-cpp.so.18.1 $installdir/usr/lib64/libclang-cpp.so.18.1

# Make sure that the .defs files are arch-dependent
pushd $installdir/usr/include/llvm/Config
Expand Down
32 changes: 16 additions & 16 deletions packages/l/llvm/pspec_x86_64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Name>llvm</Name>
<Homepage>http://llvm.org/</Homepage>
<Packager>
<Name>Reilly Brogan</Name>
<Email>solus@reillybrogan.com</Email>
<Name>Joey Riches</Name>
<Email>josephriches@gmail.com</Email>
</Packager>
<License>Apache-2.0 WITH LLVM-exception</License>
<PartOf>programming</PartOf>
Expand Down Expand Up @@ -74,7 +74,7 @@
</Description>
<PartOf>emul32</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm</Dependency>
<Dependency release="121">llvm</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="library">/usr/lib32/LLVMgold.so</Path>
Expand Down Expand Up @@ -104,8 +104,8 @@
</Description>
<PartOf>programming.devel</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm-32bit</Dependency>
<Dependency release="120">llvm-devel</Dependency>
<Dependency release="121">llvm-32bit</Dependency>
<Dependency release="121">llvm-devel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="executable">/usr/bin/llvm-config32</Path>
Expand Down Expand Up @@ -289,8 +289,8 @@
</Description>
<PartOf>programming</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm</Dependency>
<Dependency releaseFrom="120">llvm-devel</Dependency>
<Dependency release="121">llvm</Dependency>
<Dependency releaseFrom="121">llvm-devel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="executable">/usr/bin/UnicodeNameMappingGenerator</Path>
Expand Down Expand Up @@ -756,7 +756,7 @@
</Description>
<PartOf>emul32</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm-32bit</Dependency>
<Dependency release="121">llvm-32bit</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="library">/usr/lib32/libclang-cpp.so.18.1</Path>
Expand All @@ -774,8 +774,8 @@
</Description>
<PartOf>programming.devel</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm-clang-32bit</Dependency>
<Dependency releaseFrom="120">llvm-clang-devel</Dependency>
<Dependency release="121">llvm-clang-32bit</Dependency>
<Dependency releaseFrom="121">llvm-clang-devel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="library">/usr/lib/clang/18/lib/i386-pc-linux-gnu/clang_rt.crtbegin.o</Path>
Expand Down Expand Up @@ -1075,7 +1075,7 @@
</Description>
<PartOf>programming.devel</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm-clang</Dependency>
<Dependency release="121">llvm-clang</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="executable">/usr/bin/clang-tblgen</Path>
Expand Down Expand Up @@ -2266,7 +2266,7 @@
</Description>
<PartOf>programming.devel</PartOf>
<RuntimeDependencies>
<Dependency release="120">llvm</Dependency>
<Dependency release="121">llvm</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="executable">/usr/bin/FileCheck</Path>
Expand Down Expand Up @@ -7683,12 +7683,12 @@
</Files>
</Package>
<History>
<Update release="120">
<Date>2024-07-03</Date>
<Update release="121">
<Date>2024-10-15</Date>
<Version>18.1.8</Version>
<Comment>Packaging update</Comment>
<Name>Reilly Brogan</Name>
<Email>solus@reillybrogan.com</Email>
<Name>Joey Riches</Name>
<Email>josephriches@gmail.com</Email>
</Update>
</History>
</PISI>