jbeverly / pam_ssh_agent_auth

Moving pam_ssh_agent_auth to github as primary development location
Other
99 stars 29 forks source link

Configure blows up because of implicit declaration of exit() #45

Open Artoria2e5 opened 12 months ago

Artoria2e5 commented 12 months ago

Current git HEAD gives:

configure:9081: checking compiler and flags for sanity
configure:9095: gcc -o conftest -g -O2 -fPIC -Wall -Wpointer-arith -Wuninitialized -fstack-protector-all -fno-common  -I/usr/local/opt/icu4c/include -I/usr/local/opt/ruby/include -I/usr/local/opt/sqlite/include -I/usr/local/opt/gettext/include -I/usr/local/opt/qt/include  -L/usr/local/opt/icu4c/lib -L/usr/local/opt/ruby/lib -L/usr/local/opt/sqlite/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/qt/lib -fstack-protector-all conftest.c  >&5
conftest.c:134:12: error: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
int main(){exit(0);}
           ^
conftest.c:134:12: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 error generated.
configure:9095: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h, irrelevant */
| /* end confdefs.h.  */
| 
| #include <stdio.h>
| int main(){exit(0);}
| 
configure:9100: result: no
configure:9102: error: *** compiler cannot create working executables, check config.log ***

gcc --version gives:

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Running autoreconf does not help, because this test is written directly in configure.ac. Changing the CFLAGS to add -Wno-error=all at the CFLAGS="$CFLAGS -fPIC -Wall -Wpointer-arith -Wuninitialized" bit helps, but the right way to do it is probably fixing the invocation. Because well, the compiler does not seem to be in the wrong here.

crashkopf commented 4 months ago

I got bitten by this issue today. I believe the root cause (for my system anyways) is an update to GCC's defaults (-Werror=implicit-function-declaration is now default behavior) see: https://gcc.gnu.org/gcc-14/porting_to.html

In other words, the configure test may be written expecting GCC version <=13. Not sure about clang's history with this. Best guess as to a permanent solution is using a newer version of autoconf.

Artoria2e5 commented 4 months ago

Implicit declaration is (in recent code) usually unintended, so personally I lean towards adding an include. https://manned.org/exit.3p does indicate that under POSIX, stdlib is the correct include.

crashkopf commented 4 months ago

Agreed that the include should be added, but what is the source of the test code? Was it hand-written into configure.ac or was it generated by some tool like autoscan? It looks like there are several tests that don't include stdlib.h before calling exit().

Then again, maybe the wisest thing to do is modify the configure script and just move on with life. :/

crashkopf commented 4 months ago

configure.patch.txt This patch fixes all the implicit-function-declaration errors in the configure script.

With the above fixes configure runs, and maybe even gets correct results from all it's tests, but unfortunately the build still fails with incompatible-pointer-type errors in ssh-ecdsa.c I'll open a separate issue for those.