Skip to content

Commit b434ae8

Browse files
committed
Fix shared object on x86-64 Linux having executable stack ELF flag enabled (#481)
Fix shared object on x86-64 Linux having executable stack ELF flag enabled (#481) Signed-off-by: Harold Brenes <[email protected]>
1 parent 74b7189 commit b434ae8

File tree

9 files changed

+291
-248
lines changed

9 files changed

+291
-248
lines changed

.github/actions/build-harvester.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ echo "Harvester artifact: ${artifact_name}"
4242
echo 'cmake --version'
4343
cmake --version
4444

45-
mkdir -p build-harvester
46-
pushd build-harvester
47-
cmake .. -DCMAKE_BUILD_TYPE=Release -DBB_HARVESTER_ONLY=ON
48-
49-
cmake --build . --config Release --target bladebit_harvester
45+
./build-harvester.sh
5046

5147
if [[ "$host_os" == "windows" ]]; then
5248
OBJDUMP=$("${CUDA_PATH}"\\bin\\cuobjdump Release\\bladebit_harvester.dll)
5349
elif [[ "$host_os" == "linux" ]]; then
54-
OBJDUMP=$(/usr/local/cuda/bin/cuobjdump libbladebit_harvester.so)
50+
OBJDUMP=$(/usr/local/cuda/bin/cuobjdump "build-harvester/libbladebit_harvester.so")
51+
52+
# Check for the right GNU_STACK flags
53+
script_path=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
54+
# echo $script_path
55+
${script_path}/check-elf-gnu-stack-flags.sh "build-harvester/libbladebit_harvester.so"
5556
fi
5657

57-
cmake --install . --prefix harvester_dist
58+
cmake --install "build-harvester" --prefix harvester_dist
5859
pushd harvester_dist/green_reaper
5960

6061
if [[ "$host_os" == "windows" ]]; then
@@ -109,5 +110,4 @@ if [[ "$CI" == "true" ]]; then
109110
echo "harvester_artifact_path=$harvester_artifact_path" >> "$GITHUB_ENV"
110111
fi
111112

112-
popd
113113
ls -la
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
4+
file_path=$1
5+
flag=$(readelf -e $file_path | grep GNU_STACK -A 1 | tail -n 1 | tr -s ' ' | cut -f4 -d' ')
6+
7+
echo "Flag: GNU_STACK flag: $flag"
8+
9+
if [[ $flag != "RW" ]]; then
10+
>&2 echo "GNU_STACK flag is expected to be set to 'RW', but got '$flag'"
11+
exit 1
12+
fi

.github/workflows/attach-release-assets.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ jobs:
3030
echo "Release Version: $BB_VERSION"
3131
3232
artifacts=(
33-
bladebit-v${BB_VERSION}-ubuntu-x86-64.tar.gz
34-
bladebit-v${BB_VERSION}-almalinux-x86-64.tar.gz
35-
bladebit-v${BB_VERSION}-ubuntu-arm64.tar.gz
36-
bladebit-v${BB_VERSION}-almalinux-arm64.tar.gz
37-
bladebit-v${BB_VERSION}-windows-x86-64.zip
38-
bladebit-cuda-v${BB_VERSION}-ubuntu-x86-64.tar.gz
39-
bladebit-cuda-v${BB_VERSION}-almalinux-x86-64.tar.gz
40-
bladebit-cuda-v${BB_VERSION}-ubuntu-arm64.tar.gz
41-
bladebit-cuda-v${BB_VERSION}-windows-x86-64.zip
33+
# bladebit-v${BB_VERSION}-ubuntu-x86-64.tar.gz
34+
# bladebit-v${BB_VERSION}-rhl-x86-64.tar.gz
35+
# bladebit-v${BB_VERSION}-ubuntu-arm64.tar.gz
36+
# bladebit-v${BB_VERSION}-rhl-arm64.tar.gz
37+
# bladebit-v${BB_VERSION}-windows-x86-64.zip
38+
# bladebit-cuda-v${BB_VERSION}-ubuntu-x86-64.tar.gz
39+
# bladebit-cuda-v${BB_VERSION}-rhl-x86-64.tar.gz
40+
# bladebit-cuda-v${BB_VERSION}-ubuntu-arm64.tar.gz
41+
# bladebit-cuda-v${BB_VERSION}-windows-x86-64.zip
4242
green_reaper-v${BB_VERSION}-linux-x86-64.tar.gz
43-
green_reaper-v${BB_VERSION}-linux-ARM64.tar.gz
44-
green_reaper-v${BB_VERSION}-macos-x86-64.tar.gz
45-
green_reaper-v${BB_VERSION}-macos-arm64.tar.gz
46-
green_reaper-v${BB_VERSION}-windows-x86-64.zip
43+
# green_reaper-v${BB_VERSION}-linux-ARM64.tar.gz
44+
# green_reaper-v${BB_VERSION}-macos-x86-64.tar.gz
45+
# green_reaper-v${BB_VERSION}-macos-arm64.tar.gz
46+
# green_reaper-v${BB_VERSION}-windows-x86-64.zip
4747
)
4848
4949
mkdir -p bin
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
name: Build Harvester Release Assets
2+
on:
3+
push:
4+
branches: ['*']
5+
workflow_dispatch:
6+
7+
env:
8+
CI_BLADEBIT: 1 # Our own CI, that is, not being built as a dependency
9+
10+
jobs:
11+
build-harvester-linux-x86-64:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: ghcr.io/chia-network/build-images/manylinux_cuda_x86_64:latest
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- name: Set Env
20+
uses: Chia-Network/actions/setjobenv@main
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Get Version Number
25+
id: version_number
26+
shell: bash
27+
run: ./.github/actions/get-version.sh ubuntu x86-64
28+
29+
- name: Install Prerequisites
30+
shell: bash
31+
run: |
32+
set -eo pipefail
33+
yum group install -y "Development Tools"
34+
yum install -y sudo make git wget subscription-manager
35+
36+
- name: Build Harvester
37+
shell: bash
38+
run: |
39+
export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-x86-64.tar.gz"
40+
echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV"
41+
# emits env.harvester_artifact_path
42+
bash .github/actions/build-harvester.sh --artifact "${artifact_name}"
43+
44+
- name: Upload Harvester Artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: ${{ env.harvester_artifact_name }}
48+
path: ${{ env.harvester_artifact_path }}
49+
if-no-files-found: error
50+
51+
# build-harvester-linux-arm64:
52+
# runs-on: ubuntu-24.04-arm
53+
# container:
54+
# image: ghcr.io/chia-network/build-images/manylinux_cuda_aarch64:latest
55+
# steps:
56+
# - name: Checkout Repo
57+
# uses: actions/checkout@v4
58+
59+
# - name: Set Env
60+
# uses: Chia-Network/actions/setjobenv@main
61+
# env:
62+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
# - name: Cache DNF packages
65+
# uses: actions/cache@v4
66+
# with:
67+
# path: /var/cache/dnf
68+
# key: ${{ runner.os }}-dnf-${{ hashFiles('**/your-build-file') }}
69+
# restore-keys: |
70+
# ${{ runner.os }}-dnf-
71+
72+
# - name: Get Version Number
73+
# id: version_number
74+
# shell: bash
75+
# run: ./.github/actions/get-version.sh rhl arm64
76+
77+
# - name: Install Prerequisites
78+
# shell: bash
79+
# run: |
80+
# set -eo pipefail
81+
# export module_platform_id=platform:el10
82+
# export MODULE_PLATFORM_ID=platform:el10
83+
# export PLATFORM_ID=platform:el10
84+
# uname -a
85+
# cat /etc/os-release
86+
# yum install -y dnf
87+
# dnf install -y epel-release
88+
# dnf install -y dnf-plugins-core
89+
# dnf makecache
90+
# dnf install -y kernel-headers.aarch64 kernel-devel.aarch64 tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms
91+
# dnf install -y cmake
92+
# dnf group install -y "Development Tools"
93+
# dnf install -y gmp-devel numactl-devel make git wget sed
94+
95+
# - name: Build Harvester
96+
# shell: bash
97+
# run: |
98+
# export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-ARM64.tar.gz"
99+
# echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV"
100+
# # emits env.harvester_artifact_path
101+
# bash .github/actions/build-harvester.sh --artifact "${artifact_name}"
102+
103+
# - name: Upload Harvester Artifact
104+
# uses: actions/upload-artifact@v4
105+
# with:
106+
# name: ${{ env.harvester_artifact_name }}
107+
# path: ${{ env.harvester_artifact_path }}
108+
# if-no-files-found: error
109+
110+
# build-harvester-macos-arm64:
111+
# runs-on: macos-latest
112+
# steps:
113+
# - name: Cleanup Environment
114+
# uses: Chia-Network/actions/clean-workspace@main
115+
116+
# - name: Checkout Repo
117+
# uses: actions/checkout@v4
118+
119+
# - name: Set Env
120+
# uses: Chia-Network/actions/setjobenv@main
121+
# env:
122+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
124+
# - name: Get Version Number
125+
# id: version_number
126+
# run: bash -e .github/actions/get-version.sh macos arm64
127+
128+
# - name: Build Harvester
129+
# shell: bash
130+
# run: |
131+
# export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-arm64.tar.gz"
132+
# echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV"
133+
# # emits env.harvester_artifact_path
134+
# bash .github/actions/build-harvester.sh --artifact "${artifact_name}"
135+
136+
# - name: Upload Harvester Artifact
137+
# uses: actions/upload-artifact@v4
138+
# with:
139+
# name: ${{ env.harvester_artifact_name }}
140+
# path: ${{ env.harvester_artifact_path }}
141+
# if-no-files-found: error
142+
143+
# build-harvester-macos-x86-64:
144+
# runs-on: macOS-13
145+
# steps:
146+
# - name: Cleanup Environment
147+
# uses: Chia-Network/actions/clean-workspace@main
148+
149+
# - name: Checkout Repo
150+
# uses: actions/checkout@v4
151+
152+
# - name: Set Env
153+
# uses: Chia-Network/actions/setjobenv@main
154+
# env:
155+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
157+
# - name: Get Version Number
158+
# id: version_number
159+
# run: bash -e .github/actions/get-version.sh macos x86-64
160+
161+
# - name: Build Harvester
162+
# shell: bash
163+
# run: |
164+
# export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-x86-64.tar.gz"
165+
# echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV"
166+
# # emits env.harvester_artifact_path
167+
# bash .github/actions/build-harvester.sh --artifact "${artifact_name}"
168+
169+
# - name: Upload Harvester Artifact
170+
# uses: actions/upload-artifact@v4
171+
# with:
172+
# name: ${{ env.harvester_artifact_name }}
173+
# path: ${{ env.harvester_artifact_path }}
174+
# if-no-files-found: error
175+
176+
# build-harvester-windows-x86-64:
177+
# runs-on: windows-2022
178+
# steps:
179+
# - name: Checkout Repo
180+
# uses: actions/checkout@v4
181+
182+
# - name: Set Env
183+
# uses: Chia-Network/actions/setjobenv@main
184+
# env:
185+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186+
187+
# - name: Get Version Number
188+
# id: version_number
189+
# shell: bash
190+
# run: ./.github/actions/get-version.sh windows x86-64
191+
192+
# - name: Install Prerequisites
193+
# shell: powershell
194+
# run: |
195+
# choco install -y make
196+
# choco install -y wget
197+
# choco install -y sed
198+
199+
# - name: Setup CUDA
200+
# uses: Jimver/[email protected]
201+
# id: cuda-toolkit
202+
# with:
203+
# cuda: '12.6.2'
204+
# method: network
205+
206+
# - name: Verify CUDA
207+
# shell: bash
208+
# run: |
209+
# echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}"
210+
# echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}"
211+
# nvcc -V
212+
213+
# - name: Build Harvester
214+
# shell: bash
215+
# run: |
216+
# export artifact_name="green_reaper-v${{ env.BB_VERSION }}-windows-x86-64.zip"
217+
# echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV"
218+
# # emits env.harvester_artifact_path
219+
# bash .github/actions/build-harvester.sh --artifact "${artifact_name}"
220+
# env:
221+
# CUDA_PATH: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}
222+
223+
# - name: Upload Harvester Artifact
224+
# uses: actions/upload-artifact@v4
225+
# with:
226+
# name: ${{ env.harvester_artifact_name }}
227+
# path: ${{ env.harvester_artifact_path }}
228+
# if-no-files-found: error

0 commit comments

Comments
 (0)