| Summary: | Compilation fails with clang | ||
|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | Julien Bigot <julien> |
| Component: | Miscellaneous | Assignee: | Assigned to nobody <unassigned-bugs> |
| Status: | CLOSED FIXED | ||
| Severity: | enhancement | CC: | djm, dtucker, me |
| Priority: | P5 | ||
| Version: | 9.1p1 | ||
| Hardware: | amd64 | ||
| OS: | Linux | ||
| Bug Depends on: | |||
| Bug Blocks: | 3480 | ||
|
Description
Julien Bigot
2022-10-11 02:39:57 AEDT
This code should only be compiled when libc fails to provide asprintf(), which most modern ones do (inc. glibc). So the problem is more likely configure failing to detect its presence. Can you search though config.log to see what went wrong? The log in the referenced bug does in fact detect asprintf and set "#define HAVE_ASPRINTF 1" so that code should not even be compiled on that configuration:
configure:11975: /opt/spack/lib/spack/env/clang/clang -o conftest -g -O2 -pipe -Wunknown-warning-option -Qunused-arguments -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -Wmisleading-indentation -Wbitwise-instead-of-logical -fno-strict-aliasing -mretpoline -D_FORTIFY_SOURCE=2 -ftrapv -fzero-call-used-regs=all -fno-builtin-memset -fstack-protector-strong -fPIE -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -fstack-protector-strong -pie conftest.c -lutil -lz >&5
conftest.c:151:18: warning: format string missing [-Wformat]
return asprintf ();
~~~~~~~~ ^
1 warning generated.
configure:11975: $? = 0
configure:11975: result: yes
[...]
| #define HAVE_ASPRINTF 1
I am also not able to reproduce on Fedora 36 with a locally built clang 15:
$ /opt/clang-15.0.1/bin/clang --version
clang version 15.0.1 (https://github.com/llvm/llvm-project.git b73d2c8c720a8c8e6e73b11be4e27afa6cb75bdf)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/clang-15.0.1/bin
Is something modifying config.h, or is it picking up a config.h from some other location?
Hi, I am not the expert of spack packaging of openssh. I only reported the issue there and the spack packager pointed me here as he considered the issue to be upstream. The config.log is attached to the spack issue: https://github.com/spack/spack/files/9741543/config.log in there, I see ac_cv_func_asprintf=yes As you can see in this issue https://github.com/spack/spack/issues/33131 , I provided docker image you can use to reproduce the bug: ghcr.io/pdidev/test_env/builder:latest-clang-2e69267 In this image, you can just run: ``` spack -e pdienv add -l mpi openssh spack -e pdienv install --show-log-on-error --fail-fast ``` I don't see why the config.h would be tampered with and looking at the spack openssh "recipe", https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/openssh/package.py I don't see anything pointing to it. openssh undefs it here:
/*
* Don't let systems with broken printf(3) avoid our replacements
* via asprintf(3)/vasprintf(3) calling libc internally.
*/
#if defined(BROKEN_SNPRINTF)
# undef HAVE_VASPRINTF
# undef HAVE_ASPRINTF
#endif
given BROKEN_SNPRINTF=1 in the config.log.
And it seems like the relevant configure test is broken?
| #include <stdio.h>
| #include <stdlib.h>
| #include <string.h>
| #ifdef HAVE_SNPRINTF
| main()
| {
| char buf[50];
| char expected_out[50];
| int mazsize = 50 ;
| #if (SIZEOF_LONG_INT == 8)
| long int num = 0x7fffffffffffffff;
| #else
| long long num = 0x7fffffffffffffffll;
| #endif
| strcpy(expected_out, "9223372036854775807");
| snprintf(buf, mazsize, "%lld", num);
| if(strcmp(buf, expected_out) != 0)
| exit(1);
| exit(0);
| }
| #else
| main() { exit(0); }
| #endif
there's no `int main` and it errors with
conftest.c:367:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
It's clang 15, see https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626 or https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics Applied https://github.com/openssh/openssh-portable/pull/349, thanks. OpenSSH 9.3 has been released. Close resolved bugs |