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

Only use GNU specific strerror_r() API when __GLIBC__ is defined. #791

Merged
merged 1 commit into from Jun 22, 2023

Conversation

DimitryAndric
Copy link
Contributor

As reported in https://pkg-status.freebsd.org/gohan05/data/maini386PR265425-default/2022-12-06_12h24m32s/logs/errors/augeas-1.12.0_3.log, augeas uses a GNU specific strerror_r() invocation, even when compiling on FreeBSD. This is because gnulib's regex.h defines __USE_GNU when _GNU_SOURCE is used.

It is better to also check for __GLIBC__, since the GNU specific variant of strerror_r() is really a glibc invention. This will also make the code compile without warnings on Alpine Linux, which uses musl libc.

@igalic
Copy link

igalic commented Dec 8, 2022

this makes me wonder if #760 is also glibc only

@igalic
Copy link

igalic commented Dec 14, 2022

@georgehansper as per @smortex's review, this has been merged in FreeBSD's port system: freebsd/freebsd-ports@48d5133

@georgehansper
Copy link
Member

Thanks for this PR and the comments. I will take a closer look in good time, to ensure there are no unwanted side-effects.

@georgehansper
Copy link
Member

I have downloaded FreeBSD 13.1 and compiled augeas 1.14.0 successfully from

Both of these compile without need of any modification to the source tree of augeas.

I have also downloaded the current FreeBSD 14.0 image (20221117), and successfully compiled augeas 1.14.0 from the above tarball, again, without any modification to the augeas source tree.

(FYI: The 1.12.0 tarball also compiles without modification on FreeBSD 13.1 and 14.0)

I cannot see any necessity for this PR.

Thoughts?

@igalic
Copy link

igalic commented Dec 18, 2022

FreeBSD CURRENT is in LLVM 14

The ports tree imports new versions and builds the tree with these versions.

@DimitryAndric
Copy link
Contributor Author

This was only in preparation for the import of llvm and clang 15.0 into FreeBSD. We do a few runs of the whole ports tree with the new compiler, linker and standard C++ library, to see if there any problems.

One of the ports that resulted in a build error was augeas, specifically because it warned on the incorrect return value conversion (char* to int). Of course on the FreeBSD ports side, we could simply suppress this warning and continue as if everything was all right, but it seemed better to fix this properly.

That said, GNU libc is really the only C library that uses the char *strerror_r(int, char *, size_t) variant:
https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=54dd8344de25a2cdb3f4eac2ac4d0878d1b0d756;hb=HEAD#l422
Everybody else uses the POSIX variant, int strerror_r(int, char *, size_t).

@igalic
Copy link

igalic commented Dec 18, 2022

thank you so much @DimitryAndric, that's a much more thorough explanation than i could have possibly mustered

Copy link

@thesamesam thesamesam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hit this downstream in Gentoo with musl as well.

@georgehansper georgehansper merged commit 792fb22 into hercules-team:master Jun 22, 2023
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.

None yet

5 participants