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

-pthread appended to CFLAGS even though the compiler is IBM XLC #8276

Closed
dcassioli opened this issue Jan 13, 2022 · 6 comments
Closed

-pthread appended to CFLAGS even though the compiler is IBM XLC #8276

dcassioli opened this issue Jan 13, 2022 · 6 comments
Labels

Comments

@dcassioli
Copy link
Contributor

https://github.com/curl/curl/blob/master/configure.ac#:~:text=AC_CHECK_FUNC(pthread_create%2C%20%5BUSE_THREADS_POSIX,PTHREAD%3D%22%20%2Dpthread%22

In configure.ac (and the generated configure script) the -pthread flag gets appended to CFLAGS even in the case of IBM XLC compiler. The issue was experienced in AIX 7.1 with XLC version 11.1.

The -pthread flag has no meaning in XLC, and it's probably getting interpreted as -p (enable profiling) -t (list of toolchain programs to prepend the prefix specified by the -B flag to, i.e., 'a' for 'assembler', 'l' for 'linker', etc.), and then 'hread' is parsed as argument for -t (which is garbage, so the flag is simply discarded with a warning).

In discussion: https://curl.se/mail/lib-2019-03/0049.html a possible fix is proposed.

@bagder bagder added the build label Jan 13, 2022
@bagder
Copy link
Member

bagder commented Jan 13, 2022

The patch back then seems to suggest to check for *-ibm-aix* and treat it like hpux is already treated in there: it simply skips adding a command line option but then also disables threading (and the threaded resolver). It's a very crude "fix".

1.Isn't there a chance that gcc/clang can run on AIX and have such an option?
2. Don't you rather want the corresponding xlc take used so that you can use the threaded resolver?

@bagder
Copy link
Member

bagder commented Jan 13, 2022

I think it would make sense if you would write up a PR for the change you think makes sense for you on that platform. We don't have many AIX users or developers around.

@dcassioli
Copy link
Contributor Author

dcassioli commented Jan 14, 2022

The patch back then seems to suggest to check for *-ibm-aix* and treat it like hpux is already treated in there: it simply skips adding a command line option but then also disables threading (and the threaded resolver). It's a very crude "fix".

You are right, of course, I'm aware it's not a real fix but it allows a user to pass the -qthreaded flag to C/CPPFLAGS manually (not much of an improvement, I admit) and, most of all, it doesn't backfire and result in having profiling enabled.

1.Isn't there a chance that gcc/clang can run on AIX and have such an option?

I've found some literature about gcc working on AIX, but it's not supported by IBM and it feels like a "hack". I'd rather have XLC fully supported (apart from this little issue, curl is building fine).

  1. Don't you rather want the corresponding xlc take used so that you can use the threaded resolver?

I'd love to. The main reason why I opened this issue was to (indirectly) ask whether some patch was already being implemented; if you don't mind, I'm going to test a possible solution and submit it as a PR.

Thank you for your patience and your quick reply.

@bagder
Copy link
Member

bagder commented Jan 14, 2022

I've found some literature about gcc working on AIX, but it's not supported by IBM and it feels like a "hack". I'd rather have XLC fully supported (apart from this little issue, curl is building fine).

I fully support that. I was only suggesting that if gcc (might) (or in fact another compiler in general) run on AIX, then checking for the OS in configure is the wrong way to detect the compiler.

I'm going to test a possible solution and submit it as a PR.

Awesome!

@bagder bagder closed this as completed in 9cc75eb Feb 2, 2022
@asedeno
Copy link
Contributor

asedeno commented Mar 5, 2022

@dcassioli can I get your help with #8541? I do not have an AIX system to test against.

asedeno added a commit to asedeno/curl that referenced this issue Mar 5, 2022
The fix for curl#8276 proposed in curl#8374 set `CFLAGS="$CFLAGS -pthead"`
earlier than it used to be set, applying it in cases where it should
not have been applied.

This moves the AIX XLC check to a new `case $host in` block inside of
the `if test "$USE_THREADS_POSIX" != "1"` block, where
`CFLAGS="$CFLAGS -pthead"` used to happen.
@dcassioli
Copy link
Contributor Author

@dcassioli can I get your help with #8541? I do not have an AIX system to test against.

Sure, but I won't be able to test it until Monday. I'll let you know as soon as it's done.

bagder pushed a commit that referenced this issue Mar 10, 2022
The fix for #8276 proposed in #8374 set `CFLAGS="$CFLAGS -pthead"`
earlier than it used to be set, applying it in cases where it should not
have been applied.

This moves the AIX XLC check to a new `case $host in` block inside of
the `if test "$USE_THREADS_POSIX" != "1"` block, where `CFLAGS="$CFLAGS
-pthead"` used to happen.

Fixes #8541
Closes #8542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants