Re: -x assembler-with-cpp behavior different on different unixes.
Hi Karel, With Solaris 9 support gone on mainline, this can be revisited now, but this won't change anything for released versions. What shall I do for this to be at least considered? Nothing: it's already on my agenda to fix this for 4.10/5.0, thanks to your report :-) The only thing one could possibly do for older releases is to restrict passing -P to Sun as, but given the niche case that triggers this, this is almost certainly too invasive for a micro release. it turns out I spoke too soon: the Solaris 10 FCS assembler still cannot handle # line directives. It seems this only came in patch 119961-03. Given that passing -P didn't cause other issues so far, I fear removing that will have to wait until S10 support is removed. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: -x assembler-with-cpp behavior different on different unixes.
Rainer Orth r...@cebitec.uni-bielefeld.de writes: Apart from that, why are you invoking gcc with -x assembler-with-cpp when the input is clearly anything but assembler input? You're obviously lying to the compiler, and I'd go as far as claiming that you get what you deserve: garbage in, garbage out. :-) fair enough, but GHC requires to use some CPP and GNU C's provided one is very comfortable. Well, at least except on Solaris as you see... But why the -x assembler-with-cpp instead of plain -E? -E applies C tokenisation rules, so isn't a good idea for non-C input. E.g.: #define X(A, B) A##B X(,) gives an error for plain -E but is OK with -x assembler-with-cpp. (I've no idea whether is a valid Haskell token.) Thanks, Richard
Re: -x assembler-with-cpp behavior different on different unixes.
More information: It looks like gcc driver invokes cc1 with -P option which switches off linemakers on Solaris. On Linux cc1 is invoked without -P and so linemakers are presented. The question is why on Solaris -P is added to the options since I don't use it myself. It's inserted by gcc itself... Thanks, Karel On Fri, Aug 8, 2014 at 8:47 PM, Karel Gardas gard...@gmail.com wrote: Hello, GHC (Haskell compiler) is using builtin gcc's cpp for its cpp capability. The problem is a little bit different behaviour on different platform which I observed. As one of GHC's testcases completely unrelated to gcc's cpp we use: {-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () now, internally GHC calls GCC's cpp on this file with some -Is and following options (-I dir removed for brevity): /usr/bin/gcc -E -undef -traditional '-D__GLASGOW_HASKELL__=709' '-Dsolaris2_BUILD_OS=1' '-Di386_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Di386_HOST_ARCH=1' -x assembler-with-cpp T7145b.hs -o /tmp/ghc2662_0/ghc2662_1.hscpp the problem is that produced code looks: {-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () so exact copy of the input file. Now, this is with Solaris 11.1 distributed GNU C 4.5.2. I've tested also 4.6.0, 4.7.1 and 4.8.2 built by myself on the same platform and all those exhibit the same behaviour. Now, if I try the same on Ubuntu 14.04 LTS which provides GNU C 4.8.2, then I get the expected output which contains # 1 T7145b.hs # 1 command-line # 1 /usr/include/stdc-predef.h 1 3 4 # 17 /usr/include/stdc-predef.h 3 4 [ empty lines cut] # 1 command-line 2 # 1 T7145b.hs {-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () Now my question is what exactly is expected behaviour and what not. I'm mainly interested in this # 1 7145b.hs since we need it to get the source file name right in following GHC emitted warning/error messages. Is there any way how to enable those CPP marks even on Solaris? Or is Ubuntu using some distro specific patch to enable this behaviour and the behaviour itself is deprecated? Thanks! Karel
Re: -x assembler-with-cpp behavior different on different unixes.
Hi Karel, More information: It looks like gcc driver invokes cc1 with -P option which switches off linemakers on Solaris. On Linux cc1 is invoked without -P and so linemakers are presented. The question is why on Solaris -P is added to the options since I don't use it myself. It's inserted by gcc itself... you can find this explained in gcc/config/i386/sol2.h (so this behaviour is Solaris/x86-specific): /* Solaris 2/Intel as chokes on #line directives before Solaris 10. */ #undef CPP_SPEC #define CPP_SPEC %{,assembler-with-cpp:-P} %(cpp_subtarget) With Solaris 9 support gone on mainline, this can be revisited now, but this won't change anything for released versions. Apart from that, why are you invoking gcc with -x assembler-with-cpp when the input is clearly anything but assembler input? You're obviously lying to the compiler, and I'd go as far as claiming that you get what you deserve: garbage in, garbage out. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: -x assembler-with-cpp behavior different on different unixes.
Hi Rainer, On Fri, Aug 8, 2014 at 11:04 PM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote: Hi Karel, More information: It looks like gcc driver invokes cc1 with -P option which switches off linemakers on Solaris. On Linux cc1 is invoked without -P and so linemakers are presented. The question is why on Solaris -P is added to the options since I don't use it myself. It's inserted by gcc itself... you can find this explained in gcc/config/i386/sol2.h (so this behaviour is Solaris/x86-specific): /* Solaris 2/Intel as chokes on #line directives before Solaris 10. */ #undef CPP_SPEC #define CPP_SPEC %{,assembler-with-cpp:-P} %(cpp_subtarget) Thanks a lot for this reference! Hmm, I see I can't do with this anything since I'd like to use as much as possible Solaris bundled GNU C. With Solaris 9 support gone on mainline, this can be revisited now, but this won't change anything for released versions. What shall I do for this to be at least considered? Apart from that, why are you invoking gcc with -x assembler-with-cpp when the input is clearly anything but assembler input? You're obviously lying to the compiler, and I'd go as far as claiming that you get what you deserve: garbage in, garbage out. :-) fair enough, but GHC requires to use some CPP and GNU C's provided one is very comfortable. Well, at least except on Solaris as you see... Thanks a lot for your help! Karel
Re: -x assembler-with-cpp behavior different on different unixes.
Hi Karel, On Fri, Aug 8, 2014 at 11:04 PM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote: Hi Karel, More information: It looks like gcc driver invokes cc1 with -P option which switches off linemakers on Solaris. On Linux cc1 is invoked without -P and so linemakers are presented. The question is why on Solaris -P is added to the options since I don't use it myself. It's inserted by gcc itself... you can find this explained in gcc/config/i386/sol2.h (so this behaviour is Solaris/x86-specific): /* Solaris 2/Intel as chokes on #line directives before Solaris 10. */ #undef CPP_SPEC #define CPP_SPEC %{,assembler-with-cpp:-P} %(cpp_subtarget) Thanks a lot for this reference! Hmm, I see I can't do with this anything since I'd like to use as much as possible Solaris bundled GNU C. right, and even if you wanted to build gcc yourself, you'd need to patch it, which does no good for anyone else trying to build/test ghc. With Solaris 9 support gone on mainline, this can be revisited now, but this won't change anything for released versions. What shall I do for this to be at least considered? Nothing: it's already on my agenda to fix this for 4.10/5.0, thanks to your report :-) The only thing one could possibly do for older releases is to restrict passing -P to Sun as, but given the niche case that triggers this, this is almost certainly too invasive for a micro release. Apart from that, why are you invoking gcc with -x assembler-with-cpp when the input is clearly anything but assembler input? You're obviously lying to the compiler, and I'd go as far as claiming that you get what you deserve: garbage in, garbage out. :-) fair enough, but GHC requires to use some CPP and GNU C's provided one is very comfortable. Well, at least except on Solaris as you see... But why the -x assembler-with-cpp instead of plain -E? Besides, this is another example of why cpp is not really suited as a general-purpose preprocessor. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University