[LU-16518] Fix Clang build errors Created: 01/Feb/23  Updated: 29/Nov/23  Resolved: 29/Nov/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Tim Day Assignee: Tim Day
Resolution: Fixed Votes: 0
Labels: None
Environment:

Clang 15.0.6


Attachments: File sanity-flr.test_42.debug_log.tmp.1679582991.log.bz2     Text File serial.txt     Text File stdout.txt    
Issue Links:
Related
is related to LU-16961 Clang plugin build system integration Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

I've been experimenting with using Clang 15.0.6 to compile Lustre. The compiler runs into a number of build issues. Clang seems to be stricter than GCC in a few cases. Lustre can still be compiled by disabling the errors [1], but a first glance the errors seem legitimate. I'm making this ticket because I have a patch to fix some of the failures.

It seems like some Clang-based static analyzers were used in the past [2], although I'm not sure if compiling Lustre with Clang is super common. I think it could be useful to have Clang as an option for development purposes, along the lines of ClangBuiltLinux [3]. It's seems like some kind of plugin [4] was developed at some point. It would be for an old (3.0) Clang, but it could be interesting to look at.

 

[1] Errors that needed to be disabled:

 

-Wno-error=enum-conversion
-Wno-error=unused-but-set-variable
-Wno-error=uninitialized
-Wno-error=format
-Wno-error=strncat-size
-Wno-error=switch
-Wno-error=strlcpy-strlcat-size
-Wno-error=unneeded-internal-declaration
-Wno-error=self-assign
-Wno-error=tautological-constant-out-of-range-compare
-Wno-error=constant-logical-operand
-Wno-error=pointer-bool-conversion
-Wno-error=unused-function
-Wno-error=parentheses-equality
-Wno-error=deprecated-non-prototype

[2] Old Clang tickets:

https://jira.whamcloud.com/browse/LU-871

https://jira.whamcloud.com/browse/LU-2675

[3] Clang/Linux: https://clangbuiltlinux.github.io/

[4] Plugin: https://wiki.whamcloud.com/pages/viewpage.action?pageId=18645101

 

 



 Comments   
Comment by Gerrit Updater [ 01/Feb/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/49859
Subject: LU-16518 ptlrpc: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 0b0c17987308869816ec6992c63fab25fde1df5c

Comment by Gerrit Updater [ 03/Feb/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/49901
Subject: LU-16518 utils: fix unused function errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 3cec9bc9ab72b51e16fd73243673ba008089076d

Comment by Gerrit Updater [ 06/Feb/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/49916
Subject: LU-16518 misc: use fixed hash code
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 3126f6eeb6a4b5e7c64a4869cbfcdb646016b300

Comment by Gerrit Updater [ 18/Feb/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50063
Subject: LU-16518 build: llvm/clang support
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 76c664621b2415dad5b80b088ccb05d0d01a3aa4

Comment by Gerrit Updater [ 01/Mar/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50161
Subject: LU-16518 utils: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 63ee9ae891e79e2e9d1ea606e05df4d34f87b91e

Comment by Gerrit Updater [ 01/Mar/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50162
Subject: LU-16518 libcfs: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 80db385d5386673b49d9a67e08470e5162738135

Comment by Gerrit Updater [ 01/Mar/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/49916/
Subject: LU-16518 misc: use fixed hash code
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 239e826876e5e20405e14a180a8fd4377d6553b2

Comment by Gerrit Updater [ 08/Mar/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/49859/
Subject: LU-16518 ptlrpc: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 50f28f81b5aa8f8ad1c8585bd7e262910f936e50

Comment by Gerrit Updater [ 16/Mar/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50318
Subject: LU-16518 lnet: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 3a0dcf925be2a0e7dd179cc9663ec6e2ffb8c586

Comment by Gerrit Updater [ 19/Mar/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50332
Subject: LU-16518 misc: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: acb2b0e5200edeebee1b11024c81c9b351139b71

Comment by Gerrit Updater [ 21/Mar/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50161/
Subject: LU-16518 utils: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 632dc6729abcaf83aeaef8167a73ce18b9a41a67

Comment by Gerrit Updater [ 21/Mar/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50162/
Subject: LU-16518 libcfs: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: b5365d5e00aaea55d6b14d1ffc0d801c89d9f79d

Comment by Alex Zhuravlev [ 22/Mar/23 ]

this is very strange but have a look at sanity-flr/42 bisection:

COMMIT		TESTED	PASSED	FAILED		COMMIT DESCRIPTION
25a53cdc80	1	0	1	BAD	LU-16491 lfs: test getdirstripe YAML
85b76aa91a	1	0	1	BAD	LU-16610 ldiskfs: fix directory corruption on openeuler 22.03
5772650cc5	1	0	1	BAD	LU-16509 lnet: memcpy false positive in brw_test
b5365d5e00	1	0	1	BAD	LU-16518 libcfs: fix clang build errors
632dc6729a	1	0	1	BAD	LU-16518 utils: fix clang build errors
764e19186c	10	10	0	GOOD	LU-16603 protocol: add OBD_BRW_COMPRESSED
25c6b7ad28	10	10	0	GOOD	LU-16589 tests: fix hard-link failure in sanityn/55d
23224e03dc	10	10	0	GOOD	LU-16587 utils: give lfs migrate a larger buffer
2bdff20f97	10	10	0	GOOD	LU-16586 build: Remove old check for linux_selinux_enabled
404a1e827b	10	10	0	GOOD	LU-16626 build: remove python2 dependencies
Comment by Alex Zhuravlev [ 22/Mar/23 ]

if I revert LU-16518 utils: fix clang build errors, then sanity-flr/42 passes constantly.

Comment by Tim Day [ 22/Mar/23 ]

I can't seem to find a failure in Maloo, and I can't reproduce the error locally:

...
lt-lfs mirror verify: '/mnt/lustre/d42.sanity-flr/f42.sanity-flr-1' chunk [0x800000, 0xa00000) is only valid in mirror 2: skipped
lt-lfs mirror verify: '/mnt/lustre/d42.sanity-flr/f42.sanity-flr-1' chunk [0xa00000, 0x1000000) is only valid in mirror 2: skipped
lt-lfs mirror verify: '/mnt/lustre/d42.sanity-flr/f42.sanity-flr-1' chunk [0x1000000, 0xffffffffffffffff) exceeds file size 0xa00002: skipped
PASS 42 (1s)
== sanity-flr test complete, duration 2 sec ============== 19:07:38 (1679512058)
sanity-flr returned 0
Finished at Wed Mar 22 19:07:38 UTC 2023 in 3s
./auster: completed with rc 0 

Do you have some logs of the test failing that I could look at? Or some advice for reproducing the failure?

Comment by Tim Day [ 23/Mar/23 ]

Thanks for the logs. I suspect it's related to the change in liblustreapi_layout.c, specifically "uint64_t mirror_end = LUSTRE_EOF;" Initializing that variable to "0" caused some failures for sanity-flr (https://testing.whamcloud.com/test_sets/09898346-75f3-4364-807b-dfe4c2d84fef). The tests passed in Maloo using "LUSTRE_EOF", but could be causing a failure for your setup. Could you try reverting just that line? If that works, then that code might need to be refactored a bit. I'm still trying to reproduce on my end.

Comment by Alex Zhuravlev [ 25/Mar/23 ]

I suspect it's related to the change in liblustreapi_layout.c, specifically "uint64_t mirror_end = LUSTRE_EOF;" Initializing that variable to "0"

you're right, that helped and sanity-flr/42 passes with that specific change reverted.

Comment by Tim Day [ 27/Mar/23 ]

It's strange that sanity-flr/42 is unhappy when `mirror_end` get initialized. I'll try to put together a patch/small refactor to fix this.

Comment by Gerrit Updater [ 04/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/49901/
Subject: LU-16518 utils: fix unused function errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 0991267eab728e9a6e49a31e80ea91b865159b7f

Comment by Gerrit Updater [ 11/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50318/
Subject: LU-16518 lnet: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: b0297a1056a4b0ee65f4405edd407a519db594e9

Comment by Gerrit Updater [ 14/Jun/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51311
Subject: LU-16518 obd: fix style and clang error
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 6342ddece29709e8c59b4ab50075cf0f2680c175

Comment by Gerrit Updater [ 28/Jun/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50332/
Subject: LU-16518 misc: fix clang build errors
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 03ddd706d99b09790cb6251c338d4d246292cd06

Comment by Gerrit Updater [ 08/Jul/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50063/
Subject: LU-16518 build: llvm/clang support
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 7f1aa5b66b247f339a9e7c25415a9a5dd272763c

Comment by Gerrit Updater [ 08/Jul/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/51311/
Subject: LU-16518 obd: fix style and clang error
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 4fc3c208422e3f2a16f8c513cecf8fb9ede0081b

Comment by Gerrit Updater [ 03/Oct/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/52565
Subject: LU-16518 rsync: fix new clang error in lustre_rsync.c
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: b412228dc3893422cf6504ae1569a1d9c368884b

Comment by Gerrit Updater [ 03/Oct/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/52566
Subject: LU-16518 lod: fix new clang error in lod_lov.c
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 6c61e0cf8a877d0691df7df50c112595732a2a9c

Comment by Gerrit Updater [ 08/Nov/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/52565/
Subject: LU-16518 rsync: fix new clang error in lustre_rsync.c
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 6aede1254803dfbde728a6b34c627ccc924a8f79

Comment by Gerrit Updater [ 17/Nov/23 ]

"Timothy Day <timday@amazon.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/53174
Subject: LU-16518 lnet: fix uninitialized variable in api-ni.c
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 678b8d8fabcb1d5b858545d5857bc1d421ec8716

Comment by Gerrit Updater [ 18/Nov/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/52566/
Subject: LU-16518 lod: fix new clang error in lod_lov.c
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 4505225108378433e878d137cc86723aab6be0f3

Comment by Gerrit Updater [ 29/Nov/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/53174/
Subject: LU-16518 lnet: fix uninitialized variable in api-ni.c
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 0ef4e5b0c1146b68bff2e49764c047e135dafa61

Comment by Peter Jones [ 29/Nov/23 ]

Landed for 2.16

Generated at Sat Feb 10 03:27:42 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.