SimonKagstrom / kcov

Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
http://simonkagstrom.github.io/kcov/
GNU General Public License v2.0
709 stars 109 forks source link

Build multi OS for Docker #452

Closed williamdes closed 1 month ago

williamdes commented 1 month ago

Fixes #451 Fixes #450

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 69.60%. Comparing base (bf2c594) to head (ebd2ee0). Report is 10 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #452 +/- ## ========================================== - Coverage 69.85% 69.60% -0.26% ========================================== Files 55 55 Lines 4249 4250 +1 Branches 3906 3909 +3 ========================================== - Hits 2968 2958 -10 - Misses 1281 1292 +11 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

williamdes commented 1 month ago

For now build tests do not pass on Alpine, I added a new workflow Can you help ? It looks like some cmake guru is needed:

/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared: file in wrong format
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find libgcc_s.so.1: file in wrong format
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc: No such file or directory

By the way, did you forget this ?:

commit b31bdf569202087aa34681136ef0fee71e021cbc (HEAD -> multi-dist)
Author: William Desportes <williamdes@wdes.fr>
Date:   Sun Jul 14 12:19:47 2024 +0200

    chore: bump to v43

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98608be..950cfd2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.12)
 project (kcov)

-set (PROJECT_VERSION_MAJOR 39)
+set (PROJECT_VERSION_MAJOR 43)
 set (PROJECT_VERSION_MINOR 0)
 set (PROJECT_VERSION_PATCH 0)
 set (PROJECT_VERSION
SimonKagstrom commented 1 month ago

Man, you work so quickly! :-)

For now build tests do not pass on Alpine, I added a new workflow Can you help ? It looks like some cmake guru is needed:

/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/libssp_nonshared.a when searching for -lssp_nonshared

OK, so the fork-32 test fail to build (it appears, from the logs). The test was not really working anyway, so I removed it in master. Perhaps you could try to merge/rebase onto that?

By the way, did you forget this ?:


commit b31bdf569202087aa34681136ef0fee71e021cbc (HEAD -> multi-dist)
Author: William Desportes <williamdes@wdes.fr>
Date:   Sun Jul 14 12:19:47 2024 +0200

    chore: bump to v43

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98608be..950cfd2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.12)
 project (kcov)

-set (PROJECT_VERSION_MAJOR 39)
+set (PROJECT_VERSION_MAJOR 43)

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

williamdes commented 1 month ago

Man, you work so quickly! :-)

Haha, 10 years of work ;p

OK, so the fork-32 test fail to build (it appears, from the logs). The test was not really working anyway, so I removed it in master. Perhaps you could try to merge/rebase onto that?

Done

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

Maybe we should remove the Cmakelist stuff and determine the version from that constant(s) ?

williamdes commented 1 month ago

It looks like I have the same result as when I tried to make tests work into the Docker image See: https://github.com/williamdes/kcov/actions/runs/9927752250/job/27423092490#step:5:285

No tests seem to pass, not sure why

SimonKagstrom commented 1 month ago

It looks like I have the same result as when I tried to make tests work into the Docker image See: https://github.com/williamdes/kcov/actions/runs/9927752250/job/27423092490#step:5:285

No tests seem to pass, not sure why

Might be several reasons, I think. For one, it seems like maybe /sbin is not part of the PATH:

runTest (test_compiled.debuglink.runTest) ... sh: rm: not found
sh: cp: not found
objcopy: 'build-tests/main-tests-debug-file': No such file
sh: cp: not found
sh: cp: not found

but my guess is that this is caused by the alpine image not being run with --security-opt seccomp=unconfined, or alternatively that the builder runs qemu, in which case it's the same error as with the non-x86 linuxes.

Anyway, I'm OK with just building it under alpine, so if there's no easy fix, then I think we should just disable the tests there (like non-x86:es).

SimonKagstrom commented 1 month ago

Yeah, I did! The git tag is what mostly determines the version. This is for some cmakery that another guy contributed, so I'm not completely sure why it's needed. But feel free to update it!

Maybe we should remove the Cmakelist stuff and determine the version from that constant(s) ?

I can take a look at that. I guess the version should be settable from the git tag for starters at least.

williamdes commented 1 month ago

Thank you for the last commit, is there a way that I can call the function and get the output ? Like I would have done with a Makefile So I can use the output in the build docker shell script

SimonKagstrom commented 1 month ago

Thank you for the last commit, is there a way that I can call the function and get the output ? Like I would have done with a Makefile So I can use the output in the build docker shell script

Well, my commit actually didn't build on github (yes, I should have used a branch first...). I think it's due to missing tags, so I'll attempt to repair it before reverting it.

I'm not quite sure I understand what you want? You mean the version? If you have built kcov, you can get it via

ska@Simons-MacBook-Air kcov % src/kcov --version
kcov v42-149-g4cb9
williamdes commented 1 month ago

fatal: No names found, cannot describe anything.

Same as me today, see https://github.com/SimonKagstrom/kcov/pull/452/commits/ad89c0f79de11058877d44be1f6919078ef0c26d

You need to have fetch depth 0 or some other depth or maybe just try to enable fetch tags ?

I'm not quite sure I understand what you want? You mean the version? If you have built kcov, you can get it via

Indeed, but is there a way to get it before the build as I need to inject the version built into the metadata before launching docker

SimonKagstrom commented 1 month ago

The latest master should build again.

I guess it might be possible to replicate in ci.yml? It's really just boils down to git describe --abbrev=4 --tags HEAD (maybe with --git-dir).

williamdes commented 1 month ago

The latest master should build again.

Yay, can you try only switching on the fetch-tags with a fetch depth of 100 maybe ? Just trying to lower the number of commits fetched for each CI run 😄

I guess it might be possible to replicate in ci.yml? It's really just boils down to git describe --abbrev=4 --tags HEAD (maybe with --git-dir).

Not sure what you mean here

williamdes commented 1 month ago

I am still debuging tests, the PATH is okay and for some unknown reason we are not testing the installed binary in PATH but the one in src. But they both "work". See: https://github.com/williamdes/kcov/actions/runs/9928689736/job/27425308406#step:5:285

williamdes commented 1 month ago

--security-opt seccomp=unconfined

That was it, it should be documented somewhere in this project What is the exact kernel capability kcov needs ? https://docs.docker.com/engine/security/seccomp/#significant-syscalls-blocked-by-the-default-profile

williamdes commented 1 month ago

-- Found Bfd: /usr/lib/libbfd.so

b'kcov: warning: kcov: WARNING: kcov has been built without libbfd-dev (or\nkcov: binutils-dev), so the --verify option will not do anything.\n\n'

How is this warning possible ?

SimonKagstrom commented 1 month ago

Now in the process of cooking food, but let me get back in a couple of hours!

Thanks for fixing this again @williamdes !

SimonKagstrom commented 1 month ago

--security-opt seccomp=unconfined

That was it, it should be documented somewhere in this project What is the exact kernel capability kcov needs ? https://docs.docker.com/engine/security/seccomp/#significant-syscalls-blocked-by-the-default-profile

ptrace definately, and probably process_vm_readv/process_vm_writev and personality.

williamdes commented 1 month ago

It should be okay now, I updated the platform list for Debian. They do not have riscv64

SimonKagstrom commented 1 month ago

Merged, thanks a lot!

williamdes commented 1 month ago

Currently waiting on the Docker build to fail push (workflow dispatch is very cool !) after build success: https://github.com/williamdes/kcov/actions/runs/9929723485 image

williamdes commented 1 month ago

Merged, thanks a lot!

Thank you too for this very nice and active collaboration ! Let's monitor the build jobs 🤞🏻

SimonKagstrom commented 1 month ago

I'm sure it will build fie!

I saw the workflow_dispatch stuff, something to read up on in the future!

williamdes commented 1 month ago

Something I am a bit unsure about is why it looks like the docker build also triggers for PRs, maybe a side effect of workflow dispatch