-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[std module] Building std
module fails with _FORTIFY_SOURCE
#121709
Comments
@llvm/issue-subscribers-clang-modules Author: Nmlgc (nmlgc)
Tested on a relatively current trunk, but exists since at least Clang 18:
$ clang++ -O -D_FORTIFY_SOURCE -stdlib=libc++ -std=c++2c --precompile -Wno-reserved-module-identifier /usr/share/libc++/v1/std.cppm
In file included from /usr/share/libc++/v1/std.cppm:229:
/usr/share/libc++/v1/std/cstdio.inc:47:14: error: using declaration referring to 'snprintf' with internal linkage cannot be exported
47 | using std::snprintf _LIBCPP_USING_IF_EXISTS;
| ^
/usr/include/bits/stdio2.h:75:8: note: target of using declaration
75 | __NTH (snprintf (__fortify_clang_overload_arg (char *, __restrict, __s),
| ^
In file included from /usr/share/libc++/v1/std.cppm:229:
/usr/share/libc++/v1/std/cstdio.inc:48:14: error: using declaration referring to 'sprintf' with internal linkage cannot be exported
48 | using std::sprintf _LIBCPP_USING_IF_EXISTS;
| ^
/usr/include/bits/stdio2.h:37:8: note: target of using declaration
37 | __NTH (sprintf (__fortify_clang_overload_arg (char *, __restrict, __s),
| ^
In file included from /usr/share/libc++/v1/std.cppm:234:
/usr/share/libc++/v1/std/cwchar.inc:30:14: error: using declaration referring to 'swprintf' with internal linkage cannot be exported
30 | using std::swprintf _LIBCPP_USING_IF_EXISTS;
| ^
/usr/include/bits/wchar2.h:181:8: note: target of using declaration
181 | __NTH (swprintf (__fortify_clang_overload_arg (wchar_t *, __restrict, __s),
| ^
3 errors generated.
|
From the error message, it looks this is a library issue. We indeed can't export declaration with internal linkage. Previously when we met such problems, we will refactor the source to declare functions from I think we need to contact with the providers of these functions to change the linkage of these functions. Although this is not directly related to libc++, I add the libc++ tag to CC libc++ folks. |
Seems because of that glibc incorrectly (?) marks some C standard libary functions # define __fortify_function_error_function static __attribute__((__unused__)) Not sure whether we want workaround like that used in MSVC STL's |
I feel, on the one hand, we need to submit an issue report to glibc. On the other hand, giving glibc is rarely updated for most users, it is better to do some workarounds. |
std
module fails with _FORTIFY_SOURCEstd
module fails with _FORTIFY_SOURCE
Tested on a relatively current trunk, but exists since at least Clang 18:
_FORTIFY_SOURCE
is part of the defaultCFLAGS
of (at least) Arch Linux during package builds viamakepkg
, and would need to be manually removed to work with modules.The text was updated successfully, but these errors were encountered: