Fix compilation with -fno-common (new GCC 10 default)#818
Merged
natoscott merged 2 commits intoperformancecopilot:masterfrom Jan 13, 2020
Merged
Fix compilation with -fno-common (new GCC 10 default)#818natoscott merged 2 commits intoperformancecopilot:masterfrom
natoscott merged 2 commits intoperformancecopilot:masterfrom
Conversation
SDS_NOINIT is currently declared in sds.h without extern, resulting in multiple definitions across sds.h consumers. With GCC 10, the default of -fcommon option will change to -fno-common, resulting in an error: Signed-off-by: David Disseldorp <ddiss@suse.de>
The global_version_major and global_version_minor variables are declared in pmdacifs.h. Currently both cifs/pmda.c and cifs/stats.c carry definitions, resulting in an error when compiling with -fno-common (a new GCC 10 default). Signed-off-by: David Disseldorp <ddiss@suse.de>
Contributor
Author
|
FWIW, I've also submitted the sds fix upstream via antirez/sds#120 , but given the backlog of PRs and lack of activity, I doubt it'll be merged there any time soon. |
natoscott
added a commit
that referenced
this pull request
Jan 13, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As described in https://bugzilla.opensuse.org/show_bug.cgi?id=1160244
Starting from the upcoming GCC release 10, the default of -fcommon option will change to -fno-common:
In C, global variables with multiple tentative definitions will result in linker errors. Global variable accesses are also more efficient on various targets.
Porting advice:
A common mistake in C is omitting
externwhen declaring a global variable in a header file. If the header is included by several files itresults in multiple definitions of the same variable. In previous GCC versions this error is ignored. GCC 10 defaults to
-fno-common,which means a linker error will now be reported. To fix this, use
externin header files when declaring global variables, and ensure each global is defined in exactly one C file. As a workaround, legacy C code can be compiled with -fcommon.Recommendations for package maintainers: