Skip to content

Commit cb8c543

Browse files
authored
Build otelcol-config statically (#1713)
Signed-off-by: Justin Kolberg <[email protected]>
1 parent 972977b commit cb8c543

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

.github/workflows/workflow-build-otelcol-config.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
run: |
6666
echo "cache-key=go-build-${{ env.GO_VERSION }}-otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}-${{ hashFiles('pkg/tools/otelcol-config/go.sum') }}" >> $GITHUB_OUTPUT
6767
echo "restore-keys=go-build-${{ env.GO_VERSION }}-otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}-" >> $GITHUB_OUTPUT
68-
echo "toolchain-cache-key=toolchain-${{inputs.arch_os}}-${{ hashFiles('pkg/tools/otelcol-config/build-fips/config.mak', 'pkg/tools/otelcol-config/build-fips/Makefile') }}" >> $GITHUB_OUTPUT
68+
echo "toolchain-cache-key=toolchain-${{inputs.arch_os}}-${{ hashFiles('toolchains/config.mak', 'toolchains/Makefile') }}" >> $GITHUB_OUTPUT
6969
7070
- uses: actions/cache/restore@v4
7171
with:
@@ -77,7 +77,7 @@ jobs:
7777
${{ steps.get-cache-key.outputs.restore-keys }}
7878
7979
- name: Build
80-
if: '! inputs.fips'
80+
if: "! inputs.fips"
8181
run: make otelcol-config-${{inputs.arch_os}}
8282
working-directory: ./pkg/tools/otelcol-config
8383

@@ -93,19 +93,6 @@ jobs:
9393
id: rebuild-toolchain
9494
if: ${{ steps.restore-toolchain-cache.outcome == 'success' && steps.restore-toolchain-cache.outputs.cache-hit != 'true' }}
9595
run: make toolchain-${{ inputs.arch_os }} OUTPUT=/opt/toolchain -j3
96-
working-directory: ./toolchains
97-
98-
- name: Build (FIPS)
99-
if: inputs.fips && contains(inputs.arch_os, 'linux')
100-
run: |
101-
CC=$(find /opt/toolchain/bin -type f -name "*-linux-musl-gcc")
102-
test "$CC"
103-
echo "Using toolchain: $CC"
104-
make otelcol-config-${{inputs.arch_os}} \
105-
FIPS_SUFFIX="-fips" \
106-
CGO_ENABLED="1" \
107-
CC="$CC" \
108-
EXTRA_LDFLAGS="-linkmode external -extldflags '-static'"
10996
working-directory: ./pkg/tools/otelcol-config
11097

11198
- name: Build (FIPS)
@@ -118,13 +105,24 @@ jobs:
118105
FIPS_SUFFIX="-fips" \
119106
CGO_ENABLED="1" \
120107
CC="$CC" \
121-
EXTRA_LDFLAGS="-linkmode external -extldflags '-static'"
108+
LDFLAGS="-linkmode external -extldflags '-static'"
122109
working-directory: ./pkg/tools/otelcol-config
123110

124111
- name: Set binary name
125112
id: set-binary-name
126113
run: echo "binary_name=otelcol-config${FIPS_SUFFIX}-${{inputs.arch_os}}" >> $GITHUB_OUTPUT
127114

115+
- name: Show file info
116+
working-directory: ./pkg/tools/otelcol-config
117+
run: |
118+
file ${{ steps.set-binary-name.outputs.binary_name }}
119+
120+
- name: Show ldd info
121+
if: contains(inputs.arch_os, 'linux')
122+
working-directory: ./pkg/tools/otelcol-config
123+
run: |
124+
ldd ${{ steps.set-binary-name.outputs.binary_name }} || true
125+
128126
- name: Show BoringSSL symbols
129127
if: inputs.fips && contains(inputs.arch_os, 'linux')
130128
working-directory: ./pkg/tools/otelcol-config

.github/workflows/workflow-build.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- name: Determine if Windows package should be signed
7575
if: runner.os == 'Windows'
7676
env:
77-
WINDOWS_CERTIFICATE: '${{ secrets.microsoft_certificate }}'
77+
WINDOWS_CERTIFICATE: "${{ secrets.microsoft_certificate }}"
7878
run: |
7979
if [ -n "${WINDOWS_CERTIFICATE}" ]; then
8080
echo "WINDOWS_SIGNING_ENABLED=true" >> $GITHUB_ENV
@@ -134,7 +134,7 @@ jobs:
134134
working-directory: ./otelcolbuilder
135135

136136
- name: Build
137-
if: '! inputs.fips'
137+
if: "! inputs.fips"
138138
run: make otelcol-sumo-${{inputs.arch_os}}
139139
working-directory: ./otelcolbuilder
140140

@@ -174,6 +174,17 @@ jobs:
174174
id: set-binary-name
175175
run: echo "binary_name=otelcol-sumo${OTELCOL_FIPS_SUFFIX}-${{inputs.arch_os}}${OTELCOL_BINARY_EXTENSION}" >> $GITHUB_OUTPUT
176176

177+
- name: Show file info
178+
working-directory: ./otelcolbuilder/cmd
179+
run: |
180+
file ${{ steps.set-binary-name.outputs.binary_name }}
181+
182+
- name: Show ldd info
183+
if: contains(inputs.arch_os, 'linux')
184+
working-directory: ./otelcolbuilder/cmd
185+
run: |
186+
ldd ${{ steps.set-binary-name.outputs.binary_name }} || true
187+
177188
- name: Show BoringSSL symbols
178189
if: inputs.fips && contains(inputs.arch_os, 'linux')
179190
working-directory: ./otelcolbuilder/cmd
@@ -216,11 +227,11 @@ jobs:
216227
if: runner.os == 'Windows' && env.WINDOWS_SIGNING_ENABLED == 'true'
217228
uses: skymatic/code-sign-action@v3
218229
with:
219-
certificate: '${{ secrets.microsoft_certificate }}'
220-
password: '${{ secrets.microsoft_certificate_password }}'
221-
certificatesha1: '${{ secrets.microsoft_certificate_hash }}'
222-
certificatename: '${{ secrets.microsoft_certificate_name }}'
223-
description: '${{ secrets.microsoft_description }}'
230+
certificate: "${{ secrets.microsoft_certificate }}"
231+
password: "${{ secrets.microsoft_certificate_password }}"
232+
certificatesha1: "${{ secrets.microsoft_certificate_hash }}"
233+
certificatename: "${{ secrets.microsoft_certificate_name }}"
234+
description: "${{ secrets.microsoft_description }}"
224235
folder: ./otelcolbuilder/cmd
225236

226237
- name: Test binary

pkg/tools/otelcol-config/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ GO ?= go
99
OS ?= $(shell uname -s | tr A-Z a-z)
1010
ARCH ?= $(shell uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
1111

12+
FIPS_SUFFIX ?= ""
13+
1214
# Builds for darwin need to be built with CGO_ENABLED set to 1 because some telegraf
1315
# plugins that are used within the telegrafreceiver are implemented with CGO.
1416
# Example of this might be the cpu input plugin using gopsutil to the cpu stats.

0 commit comments

Comments
 (0)