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++

Cross Compiling problems

Altera_Forum
Honored Contributor II
1,304 Views

In short, I'm trying to get EPICS ported to linux over NiosII. The folks at Argonne National lab already have EPICS running on linux over x86 architectures. Among the many cross compiling problems I have run into so far, and the many more yet to come. I'm stuck with an assembler error right now. 

 

The assembler does not like the output from the compiler. However, the assembly code generated by the compiler is correct for the NiosII architecture. If I us the "-S" instead of "-c" when compiling, I get get the assembly file just fine. Then I can explicitly make the call nios2-elf-as on my assembly file to get the object file. 

 

nios2-elf-as file.s -o file.o 

 

So, my output from the compiler is correct, but during compilation it is using the wrong assembler. How do I get make to use the correct assembler. I tried to set the path in a config file.  

 

PATH=/cygdrive/c/altera/......../nios2-elf-as:($PATH) 

export PATH 

 

I bombed after trying to make again. I got 

 

*** Recursive variable 'PATH' references itself (eventually) 

 

Doug
0 Kudos
9 Replies
Altera_Forum
Honored Contributor II
456 Views

 

--- Quote Start ---  

originally posted by dcurry@Jun 30 2005, 10:56 PM 

so, my output from the compiler is correct, but during compilation it is using the wrong assembler.  how do  i get make to use the correct assembler.  i tried to set the path in a config file.  

 

path=/cygdrive/c/altera/......../nios2-elf-as:($path) 

export path 

 

i bombed after trying to make again.  i got 

 

*** recursive variable 'path' references itself (eventually) 

--- Quote End ---  

 

I think that should be 

 

$ PATH=/home/user/path/compiler/bin/:$PATH 

$ export PATH 

 

You shouldn't put the binary in the PATH variable, only the location of the binary (directory). 

 

As for the rest, I don't really know what's wrong. Can you compile a simple "hello world" program with your toolchain? If not, your installation of the toolchain must be bad.
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

typo!!  

 

I should not have been lazy, and should have just listed the whole path.  

 

PATH=/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin:$(PATH) 

export PATH
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

Even though you're working under Cygwin, I'd be careful with how you're capitalizing your filenames. Try ensuring that you're using a ".s" extension instead of a ".S" 

 

If you're still having a problem, drop down to the commandline and try running make for your kernel but add on "V=1" to your commandline arguments to make. This will force verbose output to be on (which will show each command being run). 

 

If you're having problems running from the commandline, let me know and I'll post the commands that you need here in the forum.
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

Ken, 

 

Thanks for the feed back. 

 

I am running from the command line, but I'm not working on my Kernel right now. I'm trying to get this application built to run on linux over Nios.  

 

What I meant by "-S" was my compiler flag. 

 

nios2-elf-gcc -S foo.c, instead of nios2-elf-gcc -c foo.c 

 

The compiler was passing the assembly file to the HOST assembler. By using "-S," I was able to generate the assembly file "foo.s," then call nios2-elf-as direclty and generate the object file.  

 

I'm now over this hurdle. I updated GCC_EXEC_PREFIX with the correct path to cc1, and cc1plus. I was also calling nios2-elf-gcc, when I needed to be calling nios2-elf-g++. A cut, copy, and paste error!!! 

 

The assembler is happy now that I'm calling the correct one. And for about 2 minutes, so was I. The flavor of the afternoon is with basic_string.h being called out of the ....../c++/3.4.1/bits/ directory. 

 

I'm getting errors like '_Atomic_word' does not name a type, and 

'__exchange_and_add' is not a member of '__gnu_cxx' 

 

 

Doug
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

Hmm... this one might be a little out of my league. 

 

Could you cut and past the full output from your compilation in here so that I could see the context of those messages?
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

Ken, 

 

These are defined in ....../com.microtronix.nios2linux.uClibc_1.4.0/include/bits/atomicity.h.  

 

However, they are not defined in ....../nios2-gnutools/include/c++/3.4.1/bits/atomicity.h 

 

It mentions that those defined in uClibc are not really atomic. I'm not sure what any of this means for now. I have to run off and do other things this morning, in the mean time, for your viewing pleasure!!!! 

 

Doug 

 

 

make -C O.linux-NiosII -f ../Makefile TOP=../../.. T_A=linux-NiosII install 

make[3]: Entering directory `/cygdrive/f/cygwin/build/base-3.14.7/src/libCom/O.linux-NiosII' 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/nios2-elf-g++ -c -D_POSIX_C_SOURCE=199506L -D_PO 

SIX_THREADS -D_XOPEN_SOURCE=500 -Dlinux -D__linux__ -D_REENTRANT -ansi -O3 -Wall -I. -I.. -I../.. 

/../src/libCom/bucketLib -I../../../src/libCom/ring -I../../../src/libCom/calc -I../../../src/libCom/cvtFast -I../../../ 

src/libCom/cppStd -I../../../src/libCom/cxxTemplates -I../../../src/libCom/dbmf -I../../../src/libCom/ellLib -I../../../ 

src/libCom/env -I../../../src/libCom/error -I../../../src/libCom/fdmgr -I../../../src/libCom/freeList -I../../../src/lib 

Com/gpHash -I../../../src/libCom/logClient -I../../../src/libCom/macLib -I../../../src/libCom/misc -I../../../src/libCom 

/osi -I../../../src/libCom/taskwd -I../../../src/libCom/timer -I../../../src/libCom/tsDefs -I../../../include/os/Linux - 

I../../../include -I/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/lib/gcc/nios2-elf/3.4.1/incl 

ude -I/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include -I//include ../ 

../../src/libCom/misc/ipAddrToAsciiAsynchronous.cpp 

In file included from /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../. 

./../../../include/c++/3.4.1/bits/basic_string.h:45, 

from /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../. 

./../../../include/c++/3.4.1/string:53, 

from ../../../src/libCom/misc/ipAddrToAsciiAsynchronous.cpp:25: 

/cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/include/bits/atomicity.h:25:2: 

warning:# warning stub atomicity functions are not really atomic 

In file included from /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../. 

./../../../include/c++/3.4.1/string:53, 

from ../../../src/libCom/misc/ipAddrToAsciiAsynchronous.cpp:25: 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:148: error: `_Atomic_word' does not name a type 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h: In member function `void std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_dispose(const 

_Alloc&)&#39;: 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:215: error: `__exchange_and_add&#39; is not a member of `__gnu_cxx&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h: In member function `_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_refcopy()&#39;: 

 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:226: error: `__atomic_add&#39; is not a member of `__gnu_cxx&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h: In member function `bool std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_is_leaked() co 

nst [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]&#39;: 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:203: instantiated from `_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_grab(c 

onst _Alloc&, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.tcc:184: instantiated from `std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const st 

d::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocato 

r<char>]&#39; 

../../../src/libCom/misc/ipAddrToAsciiAsynchronous.cpp:218: instantiated from here 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:182: error: &#39;const struct std::basic_string<char, std::char_traits<char>, std::allocator<char 

> >::_Rep&#39; has no member named &#39;_M_refcount&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h: In member function `void std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_set_sharable() 

[with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]&#39;: 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.tcc:541: instantiated from `static typename std::basic_string<_CharT, _Traits, _Alloc>::_Rep* 

std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_create(typename _Alloc::size_type, typename _Alloc::size_type, con 

st _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.tcc:554: instantiated from `_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_clon 

e(const _Alloc&, typename _Alloc::size_type) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::alloca 

tor<char>]&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:203: instantiated from `_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_grab(c 

onst _Alloc&, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]&#39; 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.tcc:184: instantiated from `std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const st 

d::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocato 

r<char>]&#39; 

../../../src/libCom/misc/ipAddrToAsciiAsynchronous.cpp:218: instantiated from here 

/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/libexec/gcc/nios2-elf/3.4.1/../../../../../include/c++ 

/3.4.1/bits/basic_string.h:194: error: &#39;struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_ 

Rep&#39; has no member named &#39;_M_refcount&#39; 

make[3]: *** [ipAddrToAsciiAsynchronous.o] Error 1 

make[3]: Leaving directory `/cygdrive/f/cygwin/build/base-3.14.7/src/libCom/O.linux-NiosII&#39; 

make[2]: *** [install.linux-NiosII] Error 2 

make[2]: Leaving directory `/cygdrive/f/cygwin/build/base-3.14.7/src/libCom&#39; 

make[1]: *** [libCom.install] Error 2 

make[1]: Leaving directory `/cygdrive/f/cygwin/build/base-3.14.7/src&#39; 

make: *** [src.install] Error 2
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

I thought with more info I might&#39;ve been able to help but after looking at your output, I think I&#39;m out of my depth on this one. Sorry about that. 

 

I also didn&#39;t pick up earlier on the fact that you&#39;re using C++ for your application... right now C++ isn&#39;t officially supported by us with Nios II Linux because of compiler issues. The compiler that ships with the Nios II v5.0 is compiled against newlib and we use uClibc by default. 

 

While I don&#39;t understand all the details, I&#39;ve been told by my co-workers that the iostream functionality in C++ is broken for Nios II Linux due to how gcc was compiled (i.e., against newlib vs. uClibc). I&#39;ve also been told that the STL also doesn&#39;t work. 

 

I hope the warning doesn&#39;t come to late. Perhaps others out there have been able to successfully get C++ working with Nios II Linux?
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

Ken, 

 

That is going to put a bind in things. 

 

Thanks for the update, 

Doug
0 Kudos
Altera_Forum
Honored Contributor II
456 Views

I have heard that it&#39;s possible to compile the nios2-elf tool chain under Linux against uClibc. And I&#39;ve also heard that it should solve the issues with the iostream functionality. 

 

Unfortunately, I can&#39;t give you any guarantees. We haven&#39;t tested it since the old nios-elf tool chain, and when we tried then, it failed somewhat miserably during the creation of the compiler. 

 

If you have any other questions, please feel free to ask. I&#39;ll answer if I can...
0 Kudos
Reply