[Bug c/40411] New: -std=c99 does not enable c99 mode in Solaris C library
On Solaris, the C library does not operate in c99 compliant mode by default. If c99 compliant operation is desired, the object file /usr/lib/{32,64}/values-xpg6.o needs to be linked. The details are in the Solaris standards(5) manpage. When linking using "gcc -std=c99", gcc does not instruct the linker to include this object file. -- Summary: -std=c99 does not enable c99 mode in Solaris C library Product: gcc Version: 3.4.6 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: heydowns at borg dot com GCC build triplet: sparc-sun-solaris2.10 GCC host triplet: sparc-sun-solaris2.10 GCC target triplet: sparc-sun-solaris2.10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #1 from heydowns at borg dot com 2009-06-17 15:13 --- This also applies to Solaris x86. Additionally, this only applies to Solaris 10 and later. Earlier versions of Solaris did not ship c99-compliant C library and thus do not have the values-xpg6.o object file for enabling c99-compliance. -- heydowns at borg dot com changed: What|Removed |Added GCC build triplet|sparc-sun-solaris2.10 |*-solaris2.10 GCC host triplet|sparc-sun-solaris2.10 |*-solaris2.10 GCC target triplet|sparc-sun-solaris2.10 |*-solaris2.10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #4 from heydowns at borg dot com 2009-06-17 16:39 --- Also observed on gcc 4.3.3 -- heydowns at borg dot com changed: What|Removed |Added Version|3.4.6 |4.3.3 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #5 from heydowns at borg dot com 2009-06-18 21:26 --- Was looking at modifying the spec to produce the desired results and contribute patch, however ran into trouble trying to match options containing literal colons (-std=iso9899:199409) in %{S:X} style spec. Is there a way in the spec language to escape colons? I briefly scanned the spec parsing code and nothing jumped out. If not, is there some other way to match options containing colons (without using greedy * matches, since the part after the colon is significant here...) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #7 from heydowns at borg dot com 2009-07-02 14:46 --- Created an attachment (id=18121) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18121&action=view) Proposed fix: Changes linking on solaris based on std=X and implements escapes in braced specs Attaching a fix that works here for Solaris 10 and I think would work for other Solaris versions. It changes the spec to account for the other options mentioned in comment 3, to handle the main issue of the bug (link values-xpg6.o in c99 mode), and also adds linking of values-xpg4.o as the Solaris manual suggests should be done. I wasn't sure exactly how to handle the various -std=gnu* modes, so I left those as they were. To enable matching on ':' in std=iso9899:, I had to augment the spec language, as suggested in comment 6. I realize you might want to treat this as a separate issue -- I can open a separate issue for this if you want. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #10 from heydowns at borg dot com 2009-07-04 15:03 --- "sol2-6.h doesn't exist anymore in GCC 4.4 and later. Since the patch won't be applied to GCC 4.3.x, it must be adjusted. Why was values-xpg4 only added to sol2-6.h and not to sol2.h?" As far as I could tell from the documentation available to me, values-xpg4 didn't exist until Solaris 2.6. Based on the file names I was thinking sol2-6.h was for 2.6 and above, where sol2.h had to work for 2.5, etc. I can adjust it and try it with 4.4, but do we need to be concerned with Solaris < 2.6? I will also try to research and adjust for Joseph's questions/comments on std=gnu* and c++. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #12 from heydowns at borg dot com 2009-07-10 14:41 --- Trying to give some answers to Joseph's questions in comment 9. The best documentation I found on what, exactly, the various object files do is actually the man pages for the Sun Studio compilers and the OpenSolaris source code for values-*.c Choice of values-xpg*.o and values-X*.o are someone independent, so I'm splitting up the explanation. First, values-xpg*.o: Link Tool & Flags Link ResultComment c89values-xpg4.o c99values-xpg6.o cc -xc99=all,no_libNeitherDefault -xc99 option c99 language features, no c99 library support cc -xc99=all values-xpg6.o c99 lang feat. & lib support cc -xc99=none NeitherNo c99 at all So, values-xpg6.o clearly enables c99 behavior of system libraries where there is a runtime difference. It also enables the preference of XPG4 behavior over XPG3 behavior (as below). >From looking at the OpenSolaris source code for values-xpg4.o, it is stated that linking in that object file enables "xpg4 mode for APIs which have differing runtime behavior from xpg3 to xpg4". Lastly, from man page 'standards', the only time "cc" is recommended as a compiler (instead of c89 or c99, and thus not linking any of values-xpg*.o) is when you want to conform to SVID3 or CAE XPG3. What is the runtime difference of xpg3 versus xpg4? I really don't know - maybe someone can help here. But, back to Joseph's question, the inclusion values-xpg*.o does not seem to deal with extensions to standard behavior; rather it does sound like it controls the standard to which functions should conform. Based on this I am leaning towards saying values-xpg4.o should be enabled for -std=gnu89. I'd appreciate comments in light of the above. (please note that this would make it non-trivial to link for xpg3 behavior). values-X{c,a,t,s}.o are what seem to control how strict the implementation follows the standard. Currently gcc only ever uses values-X{a,c}.o which is probably sufficient, and I don't think that this needs to change at all: -std=gnu* -> values-Xa.o otherwise -> values-Xc.o values-Xa is described as "ANSI conforming mode" whereas -Xc is "Strict ANSI mode" in the Open Solaris sources. The 'cc' man page documents -Xa as ISO C plus K&R C compatibility extensions, plus semantic changes required by ISO C, preferring ISO C semantics where there is conflict. -Xc is documented as "Strictly conforming" ISO C, no K&R extensions. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #13 from heydowns at borg dot com 2009-07-16 21:11 --- Created an attachment (id=18210) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18210&action=view) Fix updated for gcc 4.4.0, link xpg6 for c++, and link xpg4 for gnu* Updated patch against gcc 4.4.0. Also add xpg6 for c++ and xpg4 for gnu* as discussed above (this is now easily modified by changing the spec if someone who knows better can say what gnu* should do). -- heydowns at borg dot com changed: What|Removed |Added Attachment #18121|0 |1 is obsolete|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411
[Bug target/40411] -std=c99 does not enable c99 mode in Solaris C library
--- Comment #14 from heydowns at borg dot com 2009-10-09 19:38 --- Ping - anyone able to comment on or integrate this patch please? Thank you! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40411