-
Notifications
You must be signed in to change notification settings - Fork 31
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
Always pass -fno-strict-aliasing
during compilation
#714
Conversation
The ksh93 codebase is incompatible with strict aliasing, yet currently the default flags enable -fstrict-aliasing via the -Os optimization flag. Additionally, manually passing a higher level optimization flag via CCFLAGS (e.g. -O3) will result in strict aliasing becoming inadvertently enabled unless -fno-strict-aliasing is explicitly passed to disable it (cf. the Fedora and OpenSUSE build scripts for ksh[*]). This commit implements a probe that will detect the existence of -fno-strict-aliasing and use it via ${mam_cc_FLAGS}, bypassing CCFLAGS. [*]: https://src.fedoraproject.org/rpms/ksh/blob/rawhide/f/ksh.spec#_49 https://build.opensuse.org/package/view_file/shells/ksh/ksh.spec?expand=1
I have been compiling and running ksh with I need to learn more about what this means, but I need to find the time to do that first. |
Most of the strict aliasing violations in the codebase are undetected because
ksh/src/cmd/ksh93/bltins/print.c Lines 105 to 107 in 3bbe308
ksh/src/cmd/ksh93/bltins/print.c Line 139 in 3bbe308
ksh/src/cmd/ksh93/bltins/print.c Line 189 in 3bbe308
Here, prdata , which is struct print , is cast to a Shbltin_t so that it can be passed as an argument to b_print . Many more of the warnings produced by -Wstrict-aliasing=2 are likely indicative of strict aliasing violations, and that's not even the highest warning level!
Build log with the strict aliasing warning level set to 1: log.txt |
The ksh93 codebase is incompatible with strict aliasing, yet currently the default flags enable -fstrict-aliasing via the -Os optimization flag. Additionally, manually passing a higher level optimization flag via CCFLAGS (e.g. -O3) will result in strict aliasing becoming inadvertently enabled unless -fno-strict-aliasing is explicitly passed to disable it (cf. the Fedora and OpenSUSE build scripts for ksh[*]). This commit implements a probe that will detect the existence of -fno-strict-aliasing and use it via ${mam_cc_FLAGS}, bypassing CCFLAGS. [*]: https://src.fedoraproject.org/rpms/ksh/blob/rawhide/f/ksh.spec#_49 https://build.opensuse.org/package/view_file/shells/ksh/ksh.spec?expand=1
The ksh93 codebase is incompatible with strict aliasing, yet currently the default flags enable -fstrict-aliasing via the -Os optimization flag. Additionally, manually passing a higher level optimization flag via CCFLAGS (e.g. -O3) will result in strict aliasing becoming inadvertently enabled unless -fno-strict-aliasing is explicitly passed to disable it (cf. the Fedora and OpenSUSE build scripts for ksh[*]). This commit implements a probe that will detect the existence of -fno-strict-aliasing and use it via ${mam_cc_FLAGS}, bypassing CCFLAGS. [*]: https://src.fedoraproject.org/rpms/ksh/blob/rawhide/f/ksh.spec#_49 https://build.opensuse.org/package/view_file/shells/ksh/ksh.spec?expand=1
The ksh93 codebase is incompatible with strict aliasing, yet currently the default flags enable
-fstrict-aliasing
via the-Os
optimization flag. Additionally, manually passing a higher level optimization flag viaCCFLAGS
(e.g.-O3
) will result in strict aliasing becoming inadvertently enabled unless-fno-strict-aliasing
is explicitly passed to disable it (cf. the Fedora and OpenSUSE build scripts for ksh*).This commit implements a probe that will detect the existence of
-fno-strict-aliasing
and use it via${mam_cc_FLAGS}
, bypassingCCFLAGS
.References:
https://src.fedoraproject.org/rpms/ksh/blob/rawhide/f/ksh.spec#_49
https://build.opensuse.org/package/view_file/shells/ksh/ksh.spec?expand=1