Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12589 Discussions

Position Indepedent Code for Nios

Altera_Forum
Honored Contributor II
1,754 Views

Hello, 

 

I was using Quartus 13.0sp1 and had no problem compiling a library project with the compiler option -fpic. 

I just switched to Quartus 13.1 and now I receive the error: 

error: position-independent code requires the Linux ABI 

 

Why is this happening? Also, when I try to use -mno-gpopt it says that the option is not recognized. 

In fact, none of my old projects work, with the error : 

nios2-elf-g++: error: unrecognized command line option '-EL' 

 

I don't even know what that option does, but why all of a sudden are flags that are automatically generated 

in the makefile from 13.0 not working in 13.1? 

 

Why is the compiler throwing errors all of a sudden? Do I have to switch back to an earlier version of Quartus? 

Thanks, 

Jonah
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
585 Views

I'd guess that 13.1 contains a newer version of gcc. 

I only use a copy of gcc I've compiled from source - so don't know which versions are in the Quartos releases. 

I'm not sure what they mean by 'the Linux ABI'. The only thing I can think of is that PIC code needs switch statement jump tables in the .code segment (due to linker restrictions, and probably 16bit offset limits), but you don't want that for small systems where you want pure code. 

It still seems strange to require a separate option (and probably a compiler build-time one). 

 

The Altera answer if probablt 'rebuild your project' ...
0 Kudos
Altera_Forum
Honored Contributor II
585 Views

I got some answers in case anybody else has this problem. 

 

1. -EL is for little endian. While the Nios architecture specification allows for big or little endian, only little has been implemented so far, so this option has been removed. 

2. -fPIC and -fpic are not supported for bare-metal applications. Period. Older versions of the compiler allowed it but results are buggy and it shouldn't be used. This is why it is disabled in the new version of the compiler. 

3. -mno-gpopt has been omitted from the current compiler version by accident. It should reappear in a future release.
0 Kudos
Altera_Forum
Honored Contributor II
585 Views

Hmmm... 

 

1) Actually you can select 'little endian' on the Nios cpu hidden config menu - I don't know if it works. 

However the Avalon bus is big endian, so other things probably wouldn't be right - at best they would be confusing. 

 

2) At a guess it is just difficult to get the code linked correctly. This seems to be a reason to make it difficult to select position independant code, but I can't think why it should be disabled completely. There might be people who are able to sort out the environment to make it work well enough for the code they need to compile.
0 Kudos
Reply