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

new: support latest clang-formatted libs. #40

Merged
merged 2 commits into from
Jan 2, 2025
Merged
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: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ jobs:
uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/syscalls-bumper

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/syscalls-bumper/go.mod'

- name: Install deps ⛓️
run: |
sudo apt update
sudo apt install -y --no-install-recommends golang ca-certificates cmake build-essential clang-14 llvm-14 pkg-config autoconf automake libtool libelf-dev libcap-dev linux-headers-$(uname -r)
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 90
sudo update-alternatives --install /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-14 90
sudo update-alternatives --install /usr/bin/llc llc /usr/bin/llc-14 90
sudo apt install -y --no-install-recommends ca-certificates cmake build-essential clang llvm pkg-config autoconf automake libtool libelf-dev libcap-dev linux-headers-$(uname -r)

- name: Build syscalls-bumper
working-directory: ${{ github.workspace }}/syscalls-bumper
Expand Down
29 changes: 19 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ func initOpts() {
// key should be consistent with the one used by https://github.com/hrw/syscalls-table/tree/master/data/tables.
// Value should be the suffix used by libs/driver/syscall_compat_* headers.
var supportedArchs = map[string]string{
"x86_64": "x86_64",
"arm64": "aarch64",
"s390x": "s390x",
"riscv64": "riscv64",
"powerpc64": "ppc64le",
"loongarch64": "loongarch64",
"x86_64": "x86_64",
"arm64": "aarch64",
"s390x": "s390x",
"riscv64": "riscv64",
"powerpc64": "ppc64le",
"loongarch64": "loongarch64",
}

func main() {
Expand Down Expand Up @@ -389,16 +389,21 @@ func updateLibsSyscallTable(syscallMap SyscallMap) {
}

func updateLibsEventsToScTable(syscallMap SyscallMap) {
var inGeneric = false
updateLibsMap(*libsRepoRoot+"/userspace/libscap/linux/scap_ppm_sc.c",
func(lines *[]string, line string) bool {
if strings.Contains(line, "[PPME_GENERIC_") {
newLine := strings.TrimSuffix(line, "-1},")
inGeneric = true
}
if inGeneric && strings.Contains(line, "-1},") {
for key := range syscallMap {
ppmSc := "PPM_SC_" + strings.ToUpper(key)
newLine += ppmSc + ", "
// We have 43 spaces for clang formatting
newLine := strings.Repeat(" ", 43) + ppmSc + ","
*lines = append(*lines, newLine)
}
newLine += " -1},"
*lines = append(*lines, newLine)
*lines = append(*lines, strings.Repeat(" ", 43)+"-1},")
inGeneric = false
return true
}
return false
Expand All @@ -416,6 +421,8 @@ func updateLibsPPMSc(syscallMap SyscallMap) {

// add the macro char "\" to end of line
// then add all new macro values
// This is for clang formatting, we have the `\` char as 40th char right now.
line += strings.Repeat(" ", 39-len(line))
*lines = append(*lines, line+" \\")

// Properly load last enum value
Expand All @@ -434,6 +441,8 @@ func updateLibsPPMSc(syscallMap SyscallMap) {
// Eventually add the macro "\" char
// for all new elements except last one
if i < len(syscallMap) {
// This is for clang formatting, we have the `\` char as 40th char right now.
addedLine += strings.Repeat(" ", 39-len(addedLine))
addedLine += " \\"
}
*lines = append(*lines, addedLine)
Expand Down
Loading