From david.kirkby at onetel.net  Sun Mar  6 01:06:48 2011
From: david.kirkby at onetel.net (Dr. David Kirkby)
Date: Sun, 06 Mar 2011 00:06:48 +0000
Subject: [Rd] Does R use "computed gotos" - a gcc extension of C?
In-Reply-To: <alpine.DEB.2.00.1103051522190.1796@luke-inspiron>
References: <4D717337.8020806@onetel.net>
	<alpine.DEB.2.00.1103041739500.1796@luke-inspiron>
	<4D72A4C9.9010000@onetel.net>
	<alpine.DEB.2.00.1103051522190.1796@luke-inspiron>
Message-ID: <4D72D018.4050006@onetel.net>

On 03/ 5/11 09:31 PM, luke-tierney at uiowa.edu wrote:
> On Sat, 5 Mar 2011, Dr. David Kirkby wrote:
>
>> On 03/ 4/11 11:40 PM, luke-tierney at uiowa.edu wrote:
>>> On Fri, 4 Mar 2011, Dr. David Kirkby wrote:
>>>
>>>> The R manual says R will not build with gcc on 64-bit Solaris x86 with
>>>> gcc
>>>>
>>>> http://cran.r-project.org/doc/manuals/R-admin.html#Solaris
>>>>
>>>> "Tests with gcc32 on ?x86? and ?amd64? have been less successful:
>>>> ?x86? builds have failed on tests using complex arithmetic33, whereas
>>>> on ?amd64? the builds have failed to complete in several different
>>>> ways, most recently with relocation errors for libRblas.so. "
>>>>
>>>> I know what the "relocation errors" problem is. That library (and in
>>>> fact two other R libraries) all have non-PIC code in them, despite the
>>>> fact the source is compiled with the -fPIC option.
>>>>
>>>> http://blogs.sun.com/rie/entry/my_relocations_don_t_fit
>>>>
>>>> shows how to prove this. If one runs this command on Solaris:
>>>>
>>>> $ elfdump -d libRblas.so | fgrep TEXTREL
>>>>
>>>> there is some output showing that theres non-PIC code present in the R
>>>> library.
>>>>
>>>> R is compiled with -fPIC on Solaris, but certain things can cause
>>>> non-PIC code to be generated even with that option. One is by the use
>>>> of "computed gotos" which is a gcc extension. I'm wondering if R uses
>>>> any of these.
>>>
>>> Yes -- in the byte code interpreter in eval.c
>>>
>>> luke
>>
>> Thank you Luke. Do you know if there may be any others?
>
> I do not.
>
>> Do you know if that bit of code gets compiled into all 3 of the R
>> libraries? I tried replacing
>
> I do not know
>
>> #define NEXT() (__extension__ ({goto *(*pc++).v;}))
>>
>>
>> by a function which did absolutely nothing. The code built, but still
>> had the library issues.
>>
>> I'm almost certain that the definition of NEXT will cause problems,
>> but I'm not convinced it is the only issue.
>>
>> What happens if a non-GNU compiler is used? I assume these GNU
>> extensions don't get used, so how comes the code builds? Is there any
>> way I can disable the use of the GNU extensions, while still building
>> with gcc.
>
> This particular bit It only uses the gcc extensions for gcc compilers,
> and this can be turned off by defining NO_THREADED_CODE.
>
>>
>> It is rather annoying that the code has __extension__ in it, which
>> disables the warnings about the use of GCC extensions.
>>
>> http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
>>
>> Why is there a need to hide the use of the extensions?
>
> To avoid spurious warnings
>
>> I'd personally like to see just standard C used, without any
>> extensions. Then problems like I'm having would be less likely to occur.
>
> This extention is very useful for implementing byte code interpreters,
> which is why it is being used. As mentioned above, its use can be
> turned off.
>
> luke

That did not solve my problem. Every single shared library that R builds has 
this issue. I've no idea what the hell is causing it, though computed gotos are 
known as one possible source of the problems.

Is there any way to disable all GNU extensions for all files? It might be some 
other GNUim that's causing it.



-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Dave



[Rd] Does R use "computed gotos" - a gcc extension of C?
Dr. David Kirkby