[LU-13274] Building againt lustreapi using -std=c99 Created: 20/Feb/20 Updated: 10/Sep/20 Resolved: 23/Apr/20 |
|
| Status: | Resolved |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Lustre 2.14.0, Lustre 2.12.5 |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Gian-Carlo Defazio | Assignee: | James A Simmons |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | llnl | ||
| Issue Links: |
|
||||||||||||||||
| Rank (Obsolete): | 9223372036854775807 | ||||||||||||||||
| Description |
|
An application that uses the compiler flag -std=c99 wants to link against lustreapi. This was possible in version 2.8. Current versions of lustreapi use the linux kernel macro __ALIGN_KERNEL() which contains the gnuism typeof, as opposed the ISO version __typeof__. For older kernels that don't define ___ALIGN_KERNEL(), Lustre conditionally defines it. The "simplest" fix would be for the application to add -Dtypeof=__typeof__, however, this would require figuring out where in the build system to add such a flag. The other option would be to change Lustre and redefine typeof to __typeof__ in the source code of the files that use __ALIGN_KERNEL() or maybe somewhere in the Lustre build system. Are there assumptions about the C version that is used by applications that use lustreapi?
|
| Comments |
| Comment by James A Simmons [ 20/Feb/20 ] |
|
This is strange. That means any file including kernel.h breaks with std99. That includes things like sysctl.h. I will have to look how other projects work around it. |
| Comment by James A Simmons [ 20/Feb/20 ] |
|
Can you try adding #include <stddef.h> and see if it works then |
| Comment by Gian-Carlo Defazio [ 20/Feb/20 ] |
|
Adding #include <stddef.h> didn't change anything. typeof is still not recognized.
The test program I'm using is #include <stddef.h>
#include <lustre/lustreapi.h>
int main(int argc, char* argv[]) {
return 0;
}
And I get this output, with or without <stddef.h> gcc -DHAVE_CONFIG_H -I. -I../.. -include /g/g0/defazio1/lustre-release/undef.h -include /g/g0/defazio1/lustre-release/config.h -I/g/g0/defazio1/lustre-release/libcfs/include -I/g/g0/defazio1/lustre-release/lnet/include -I/g/g0/defazio1/lustre-release/lnet/include/uapi -I/g/g0/defazio1/lustre-release/lustre/include -I/g/g0/defazio1/lustre-release/lustre/include/uapi -fPIC -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS=1 -std=c99 -g -O2 -Wall -Werror -MT test_param_get_values-test_param_get_values.o -MD -MP -MF .deps/test_param_get_values-test_param_get_values.Tpo -c -o test_param_get_values-test_param_get_values.o `test -f 'test_param_get_values.c' || echo './'`test_param_get_values.c
In file included from /g/g0/defazio1/lustre-release/lustre/include/lustre/lustreapi.h:44:0,
from test_param_get_values.c:26:
/g/g0/defazio1/lustre-release/lustre/include/uapi/linux/lustre/lustre_user.h: In function 'hai_first':
/g/g0/defazio1/lustre-release/lustre/include/uapi/linux/lustre/lustre_user.h:2321:2: error: implicit declaration of function 'typeof' [-Werror=implicit-function-declaration]
size_t offset = __ALIGN_KERNEL(strlen(hal->hal_fsname) + 1, 8);
|
| Comment by James A Simmons [ 20/Feb/20 ] |
|
Ouch I see many failures. This kind of overlaps with the issues I see with the native linux lustre client and its UAPI headers. If you enable CONFIG_UAPI_HEADER_TEST you see these kinds of errors. Let me see if I can fix things up. |
| Comment by Gerrit Updater [ 21/Feb/20 ] |
|
James Simmons (jsimmons@infradead.org) uploaded a new patch: https://review.whamcloud.com/37678 |
| Comment by James A Simmons [ 21/Feb/20 ] |
|
We still have LNet UAPI headers to fix |
| Comment by Gian-Carlo Defazio [ 21/Feb/20 ] |
|
Thanks, I was able to compile my minimal test program using your patch. |
| Comment by Gian-Carlo Defazio [ 27/Feb/20 ] |
|
I commented on code review, but this is the more appropriate place... With patch 2 I can compile my dummy program with -std=c99, which just checks that the lustreapi.h header can be included. I was not able to compile liblustreapi.o with patch 2 using -std=c99, but users wouldn't do that anyways so I don't think it matters. I see that there's more going on than just changing typeof to _typeof_ depending on compiler flags. Are you fixing other potential C version errors? Or is the code rearrangement for some other reason? |
| Comment by James A Simmons [ 27/Feb/20 ] |
|
In out test suite we have 2 test that make sure you can build user land applications using our library header as well has our UAPI kernel headers. When I added the std=c99 option to gcc a bunch of errors came out. So my patch address all the issues. The nice thing about updating our internal test that it makes sure any new code landed will actually work with std=c99. As for building our user land software stack I have to check that out. Never done that. |
| Comment by Gerrit Updater [ 11/Mar/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37678/ |
| Comment by James A Simmons [ 11/Mar/20 ] |
|
More patches coming. |
| Comment by Olaf Faaland [ 17/Mar/20 ] |
|
> More patches coming. James, |
| Comment by Olaf Faaland [ 17/Mar/20 ] |
|
Does this merit a backport to b2_12 in general? It does for us. |
| Comment by James A Simmons [ 17/Mar/20 ] |
|
LNet UAPI headers and one more round of fixes for Lustre UAPI headers. I have a patch for LNet already but haven't made a maloo test for it. For the Lustre UAPI header fixes its the fallout seen from CONFIG_UAPI_HEADER_TEST. Its pretty straight forward except for some reason the linux kernel does like the use of snprintf() in hai_dump_data_field(). Haven't figured out a solution yet. |
| Comment by Gerrit Updater [ 18/Mar/20 ] |
|
James Simmons (jsimmons@infradead.org) uploaded a new patch: https://review.whamcloud.com/37971 |
| Comment by Gerrit Updater [ 18/Mar/20 ] |
|
Gian-Carlo DeFazio (defazio1@llnl.gov) uploaded a new patch: https://review.whamcloud.com/37973 |
| Comment by Gerrit Updater [ 06/Apr/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37973/ |
| Comment by Gerrit Updater [ 07/Apr/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37971/ |
| Comment by Peter Jones [ 07/Apr/20 ] |
|
simmonsja is there more to come on this ticket? |
| Comment by James A Simmons [ 07/Apr/20 ] |
|
One last patch is coming. |
| Comment by Gerrit Updater [ 13/Apr/20 ] |
|
James Simmons (jsimmons@infradead.org) uploaded a new patch: https://review.whamcloud.com/38215 |
| Comment by Gerrit Updater [ 23/Apr/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38215/ |
| Comment by Gerrit Updater [ 07/May/20 ] |
|
Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/38520 |
| Comment by Gerrit Updater [ 19/May/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38520/ |