Mailing List Archive

Smoke Failures on Alpine Linux
I recently started smoke testing Alpine Linux, and it appears that all
builds using g++ are failing early in 'make'. For example:

https://perl5.test-smoke.org/report/114477

I suspect it has something to do with the fact that Alpine uses musl
instead of glibc:

#####
cjg-alpine3:~# ldd --version
musl libc (x86_64)
Version 1.1.24
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname
cjg-alpine3:~#
#####

Unfortunately, I’m not familiar enough to do any meaningful
troubleshooting, but I’d be happy to help.

In the meantime, I’ve turned off smoke testing on g++ to keep the noise
level down.
Re: Smoke Failures on Alpine Linux [ In reply to ]
Carlos Guevara <carlos@carlosguevara.com> writes:

> I recently started smoke testing Alpine Linux, and it appears that all
> builds using g++ are failing early in 'make'. For example:
>
> https://perl5.test-smoke.org/report/114477
>
> I suspect it has something to do with the fact that Alpine uses musl
> instead of glibc:

Yes, this is the error messsage:

time64.c: In function 'void S_copy_little_tm_to_big_TM(const tm*, TM64*)':
time64.c:317:32: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
317 | dest->tm_zone = src->tm_zone;
| ~~~~~^~~~~~~
| |
| const char*


Which stems from the the fact that musl's time.h defines struct tm's
tm_zone as const char*, while time64.h only defines it as const on
glibc, QNX, Cygwin and Android (except under C++):

#ifdef HAS_TM_TM_ZONE
/* If glibc is defined or we are on QNX, use const.
* Otherwise, if we are on android, use const but
* not with g++.
*/
# if defined(__GLIBC__) || (defined(__ANDROID__) && !defined(__cplusplus)) \
|| defined(__QNX__) || defined(__CYGWIN__)
const
# endif
char *tm_zone;
#endif

This compiles (with a warning) under C, but is not allowed under C++
(which nobody appears to have tried on musl before).

Unfortunately, musl doesn't define a preprocessor symbol
(https://wiki.musl-libc.org/faq.html#Q:-Why-is-there-no-%3Ccode%3E__MUSL__%3C/code%3E-macro?),
so we would have to replace the above preprocessor conditionals with a
Configure check for the actual constness of the field.

- ilmari
--
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen
Re: Smoke Failures on Alpine Linux [ In reply to ]
> Unfortunately, musl doesn't define a preprocessor symbol
> (
> https://wiki.musl-libc.org/faq.html#Q:-Why-is-there-no-%3Ccode%3E__MUSL__%3C/code%3E-macro?
> ),
> so we would have to replace the above preprocessor conditionals with a
> Configure check for the actual constness of the field.
>
> - ilmari
>

Which, unlike checking preprocessor conditionals, is not a hack.



--
"You can be in my dream if I can be in yours." -- Bob Dylan
Re: Smoke Failures on Alpine Linux [ In reply to ]
On 16 June 2020 18:42:00 BST, David Nicol <davidnicol@gmail.com> wrote:
>> Unfortunately, musl doesn't define a preprocessor symbol
>> (
>>
>https://wiki.musl-libc.org/faq.html#Q:-Why-is-there-no-%3Ccode%3E__MUSL__%3C/code%3E-macro?
>> ),
>> so we would have to replace the above preprocessor conditionals with
>a
>> Configure check for the actual constness of the field.
>>
>> - ilmari
>>
>
>Which, unlike checking preprocessor conditionals, is not a hack.

Turns out that because of the way struct TM is used, we can make it const regardless of what the system struct tm has.

This is now smoking on https://github.com/Perl/perl5/commits/smoke-me/ilmari/struct-tm-const-tm_zone, and has been tested successfully on musl with c++.

- ilmari
Re: Smoke Failures on Alpine Linux [ In reply to ]
On 6/16/20 1:47 PM, Dagfinn Ilmari Mannsåker wrote:
>
>
> On 16 June 2020 18:42:00 BST, David Nicol <davidnicol@gmail.com> wrote:
>>> Unfortunately, musl doesn't define a preprocessor symbol
>>> (
>>>
>> https://wiki.musl-libc.org/faq.html#Q:-Why-is-there-no-%3Ccode%3E__MUSL__%3C/code%3E-macro?
>>> ),
>>> so we would have to replace the above preprocessor conditionals with
>> a
>>> Configure check for the actual constness of the field.
>>>
>>> - ilmari
>>>
>>
>> Which, unlike checking preprocessor conditionals, is not a hack.
>
> Turns out that because of the way struct TM is used, we can make it const regardless of what the system struct tm has.
>
> This is now smoking on https://github.com/Perl/perl5/commits/smoke-me/ilmari/struct-tm-const-tm_zone, and has been tested successfully on musl with c++.
>
> - ilmari
>

Ilmari,

Is the following commit what was intended to solve the problem
originally reported by Carlos Guevara on June 16?

#####
commit 926c3ce35a7ef910c55cf0964c39718ef5938ca6
Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
AuthorDate: Tue Jun 16 13:47:35 2020 +0100
Commit: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
CommitDate: Sat Jul 18 01:28:15 2020 +0100

time64: declare `tm_zone` as `const char*` unconditionally

We only ever assign from `struct tm` to `struct TM`, not the other way
around, so making this const regardless of what `struct tm` has should
be safe.
#####

Thank you very much.
Jim Keenan
Re: Smoke Failures on Alpine Linux [ In reply to ]
James E Keenan <jkeenan@pobox.com> writes:

> On 6/16/20 1:47 PM, Dagfinn Ilmari Mannsåker wrote:
>
>> Turns out that because of the way struct TM is used, we can make it
>> const regardless of what the system struct tm has.
>>
>> This is now smoking on
>> https://github.com/Perl/perl5/commits/smoke-me/ilmari/struct-tm-const-tm_zone,
>> and has been tested successfully on musl with c++.
>
> Ilmari,
>
> Is the following commit what was intended to solve the problem
> originally reported by Carlos Guevara on June 16?
>
> #####
> commit 926c3ce35a7ef910c55cf0964c39718ef5938ca6
> Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
> AuthorDate: Tue Jun 16 13:47:35 2020 +0100
> Commit: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
> CommitDate: Sat Jul 18 01:28:15 2020 +0100
>
> time64: declare `tm_zone` as `const char*` unconditionally
>
> We only ever assign from `struct tm` to `struct TM`, not the other way
> around, so making this const regardless of what `struct tm` has should
> be safe.
> #####
>
> Thank you very much.
> Jim Keenan

Yes, that's why I posted the PR in the thread, and as noted in the PR
description (but I forgot to put in the commit message):

| This fixes the build under C++ on musl libc and other systems with
| const char *tm_zone that weren't explicitly listed in the conditional.

- ilmari
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law