Skip to content

now musl have gettid() - #24245

Merged
spytheman merged 2 commits into
vlang:masterfrom
tankf33der:trace-musl
Apr 16, 2025
Merged

spytheman merged 2 commits into
vlang:masterfrom
tankf33der:trace-musl

Conversation

@tankf33der

Copy link
Copy Markdown
Contributor

Latest supported Alpine Linux version is 3.18.12, it have gettid() in manual pages.
Now test is broken, lets make it work. Tested on latest 3.21.3

94cc75377785:~/v/vlib# ../v test v/tests/trace_calls_test.v
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 FAIL  5033.210 ms /root/v/vlib/v/tests/trace_calls_test.v
> trace_fns_only_println compilation output:
================== C compilation error (from cc): ==============
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8FW0CN09699MYB2GPFW8.tmp.c:2120:31: error: conflicting types for 'gettid'; have 'u32 *(void)' {aka 'unsigned int *(void)'}
cc:  2120 | VV_EXPORTED_SYMBOL VWEAK u32* gettid(void); // exported fn v.trace_calls.vgettid
cc:       |                               ^~~~~~
cc: In file included from /usr/include/fortify/unistd.h:23,
cc:                  from /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8FW0CN09699MYB2GPFW8.tmp.c:507:
cc: /usr/include/unistd.h:198:7: note: previous declaration of 'gettid' with type 'pid_t(void)' {aka 'int(void)'}
cc:   198 | pid_t gettid(void);
cc:       |       ^~~~~~
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8FW0CN09699MYB2GPFW8.tmp.c: In function 'v__trace_calls__on_call':
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8FW0CN09699MYB2GPFW8.tmp.c:14527:29: warning: assignment to 'u32' {aka 'unsigned int'} from 'u32 *' {aka 'unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]
cc: 14527 |                         tid = gettid();
cc:       |                             ^
...
cc:       |       ^~~~~~
(note: the original output was 19 lines long; it was truncated to its first 12 lines + the last line)
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

/root/v/vlib/v/tests/trace_calls_test.v:55: fn run
   > assert res.exit_code == 0, 'compilation of $fpath failed'
     Left value (len: 1): `1`
    Right value (len: 1): `0`
        Message: compilation of vlib/v/tests/testdata/trace_calls/single_println.vv failed

> 64bit compilation output:
================== C compilation error (from cc): ==============
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8JEMC71Y50G8HM1EHM6M.tmp.c:2120:31: error: conflicting types for 'gettid'; have 'u32 *(void)' {aka 'unsigned int *(void)'}
cc:  2120 | VV_EXPORTED_SYMBOL VWEAK u32* gettid(void); // exported fn v.trace_calls.vgettid
cc:       |                               ^~~~~~
cc: In file included from /usr/include/fortify/unistd.h:23,
cc:                  from /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8JEMC71Y50G8HM1EHM6M.tmp.c:507:
cc: /usr/include/unistd.h:198:7: note: previous declaration of 'gettid' with type 'pid_t(void)' {aka 'int(void)'}
cc:   198 | pid_t gettid(void);
cc:       |       ^~~~~~
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8JEMC71Y50G8HM1EHM6M.tmp.c: In function 'v__trace_calls__on_call':
cc: /tmp/v_0/tsession_4002904cc0_01JRYX8ABNH5HRE009SG5GQZVM/single_println.01JRYX8JEMC71Y50G8HM1EHM6M.tmp.c:15212:29: warning: assignment to 'u32' {aka 'unsigned int'} from 'u32 *' {aka 'unsigned int *'} makes integer from pointer without a cast [-Wint-conversion]
cc: 15212 |                         tid = gettid();
cc:       |                             ^
...
cc:       |       ^~~~~~
(note: the original output was 19 lines long; it was truncated to its first 12 lines + the last line)
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

/root/v/vlib/v/tests/trace_calls_test.v:55: fn run
   > assert res.exit_code == 0, 'compilation of $fpath failed'
     Left value (len: 1): `1`
    Right value (len: 1): `0`
        Message: compilation of vlib/v/tests/testdata/trace_calls/single_println.vv failed
--------------------------------------------------------------------------------------------------------------------------------------------
To reproduce just failure 1 run:    '/root/v/v'  '/root/v/vlib/v/tests/trace_calls_test.v'
Summary for all V _test.v files: 1 failed, 1 total. Elapsed time: 10533 ms, on 1 job. Comptime: 5474 ms. Runtime: 5031 ms.

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22627

@tankf33der

Copy link
Copy Markdown
Contributor Author

@spytheman - how to make it work on musl:Alpine and skip musl:Ubuntu?
is it valid place for this?

@spytheman

Copy link
Copy Markdown
Contributor

@spytheman - how to make it work on musl:Alpine and skip musl:Ubuntu? is it valid place for this?

Currently there is no way for detecting that.

@spytheman

spytheman commented Apr 16, 2025 •

Copy link
Copy Markdown
Contributor

If only vlib/v/tests/trace_calls_test.v is failing, we can add a build tag at its start, that says:

// vtest build: !docker-ubuntu-musl

... which will skip it for only that CI job, but it will still fail for people that are running that test outside the CI.

@tankf33der

Copy link
Copy Markdown
Contributor Author

Then my goal to make vlib/v/tests without errors on s390x on Alpine in my own CI is unachievable.
If there is no other way, then cancel this PR and I'll think of something else

@spytheman

Copy link
Copy Markdown
Contributor

Then my goal to make vlib/v/tests without errors on s390x on Alpine in my own CI is unachievable. If there is no other way, then cancel this PR and I'll think of something else

Why?
My suggestion is to edit the vlib/v/tests/trace_calls_test.v file, and add the comment that I showed.

@spytheman

Copy link
Copy Markdown
Contributor

Your own CI can also set an env variable with the name of the job.
See cmd/v/v.v:228 for the handling of GITHUB_JOB, that allows for // vtest build: !docker-ubuntu-musl to work as a filter later.

@tankf33der

Copy link
Copy Markdown
Contributor Author

Then my goal to make vlib/v/tests without errors on s390x on Alpine in my own CI is unachievable. If there is no other way, then cancel this PR and I'll think of something else

Why? My suggestion is to edit the vlib/v/tests/trace_calls_test.v file, and add the comment that I showed.

Lost in translation.
I will do it today.

@spytheman

spytheman commented Apr 16, 2025 •

Copy link
Copy Markdown
Contributor

You can also test for musl in those tags/comments and all other $if platform_identifier {, just not for the specific version of musl directly at compile time.

@spytheman

Copy link
Copy Markdown
Contributor

I suppose that we can add detection for the distro too, since that can be of general use for other things as well.

@spytheman

Copy link
Copy Markdown
Contributor

I've rebased it over the current master (which now has a way to detect the distro too for v test runs). Lets see if the CI will pass this time.

@spytheman

Copy link
Copy Markdown
Contributor

It passed:
image

@spytheman
spytheman merged commit 1b657fa into vlang:master Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants