Skip to content

Commit

Permalink
fix: gozstd compatiblity in some environment (#761)
Browse files Browse the repository at this point in the history
* fix gozstd in some environment
  • Loading branch information
yyuuttaaoo authored Apr 3, 2023
1 parent d759e4a commit 16e18f3
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build-core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2021 iLogtail Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

name: Build Core

on:
pull_request:
push:
branches:
- main
- 1.*
jobs:
CI:
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
matrix:
go-version: [1.18]
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
runner: [ubuntu-latest, macos-latest, windows-2019]
fail-fast: true
steps:
# prepare ubuntu environment
- name: prepare ubuntu environment
if: matrix.runner == 'ubuntu-latest'
run: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y libsystemd-dev

# prepare windows environment
# https://github.com/actions/virtual-environments/issues/2549
- name: add mingw32 to path
if: matrix.runner == 'windows-2019'
shell: bash
run: |
echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
submodules: true

- name: Build Binary
if: matrix.runner == 'ubuntu-latest'
env:
BUILD_LOGTAIL_UT: ON
ENABLE_COMPATIBLE_MODE: ON
ENABLE_STATIC_LINK_CRT: ON
run: make core

result:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [CI]
steps:
- name: Build Result
run: echo "Just to make the GitHub merge button green"
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ jobs:
- name: Build Binary
if: matrix.runner == 'ubuntu-latest'
env:
BUILD_LOGTAIL_UT: ON
BUILD_LOGTAIL_UT: OFF
ENABLE_COMPATIBLE_MODE: ON
ENABLE_STATIC_LINK_CRT: ON
run: make dist
run: make dist && scripts/check_glibc.sh

- name: Build Docker
if: matrix.runner == 'ubuntu-latest'
run: scripts/check_glibc.sh && make docker
run: make docker

result:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion core/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ add_subdirectory(reader)
add_subdirectory(sender)
add_subdirectory(profiler)
add_subdirectory(sdk)
add_subdirectory(observer)
if (UNIX)
add_subdirectory(observer)
endif ()
24 changes: 22 additions & 2 deletions scripts/plugin_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@ elif [ $OS_FLAG = 2 ]; then
BUILDMODE=default
fi

# make plugins stuffs
"$CURRDIR/import_plugins.sh" "$PLUGINS_CONFIG_FILE" "$GO_MOD_FILE"
# rebuild gozstd's libzstd.a, because it is not compatible in some env
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
if [[ $MOD = "vendor" ]]; then
cd vendor/github.com/valyala/gozstd
else
"$CURRDIR/import_plugins.sh" "$PLUGINS_CONFIG_FILE" "$GO_MOD_FILE"
cd $(go env GOPATH)/pkg/mod/github.com/valyala/gozstd@*
fi

# if libzstd.a is available in the image, copy instead of rebuild
lib_name=libzstd_${GOOS}_${GOARCH}.a
if [[ -f /opt/logtail/deps/lib64/libzstd.a ]]; then
sudo cp /opt/logtail/deps/lib64/libzstd.a libzstd_${GOOS}_${GOARCH}.a
else
sudo MOREFLAGS=-fPIC make clean libzstd.a
sudo mv libzstd__.a ${lib_name}
fi
GROUP=$(id -gn $USER)
sudo chown ${USER}:${GROUP} ${lib_name}
cd -

# make plugins stuffs
go build -mod="$MOD" -modfile="$GO_MOD_FILE" -buildmode="$BUILDMODE" -ldflags="$LDFLAGS" -o "$ROOTDIR/$OUT_DIR/${NAME}" "$ROOTDIR"/plugin_main

0 comments on commit 16e18f3

Please sign in to comment.