>From my understanding, the host and target flags together specify that we are cross compiling. From, https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html, I found
If build, host, and target are all the same, this is called a *native*. If build and host are the same but target is different, this is called a *cross*. If build, host, and target are all different this is called a *canadian* (for obscure reasons dealing with Canada’s political party and the background of the person working on the build at that time). If host and target are the same, but build is different, you are using a cross-compiler to build a native for a different system. Some people call this a *host-x-host*,*crossed native*, or *cross-built native*. If build and target are the same, but host is different, you are using a cross compiler to build a cross compiler that produces code for the machine you’re building on. This is rare, so there is no common way of describing it. There is a proposal to call this a *crossback*. Thus, I should set --host and --target to riscv64-unknown-linux-gnu. Anyways, if I remove one of those flags, configure no longer believes I am cross compiling and tries to run one of the test RISCV binaries, which fails. On Monday, November 20, 2017 at 10:07:36 AM UTC-8, Adam Cozzette wrote: > > The --host riscv64-unknown-linux-gnu flag looks to me like it might be a > problem--since you're cross-compiling your build machine must not be > RISC-V, right? Does it work if you remove that one flag? > > On Sun, Nov 19, 2017 at 3:56 PM, Jerry Zhao <[email protected] > <javascript:>> wrote: > >> I need a RISCV implementation of protobuf. I tried to follow the same >> instructions for cross compiling ARM, but with the compilers set to the >> RISCV compilers. >> >> I first ran >> >> ./configure >> make >> make install >> make distclean >> >> This updated my protoc at /usr/local/bin/protoc. >> Next I ran ./configure to target RISCV. >> >> ./configure CC=riscv64-unknown-linux-gnu-gcc \ >> CXX=riscv64-unknown-linux-gnu-g++ \ >> --target riscv64-unknown-linux-gnu \ >> --host riscv64-unknown-linux-gnu \ >> --with-protoc=/usr/local/bin/protoc >> make >> >> The build proceeds normally, until I get the following error >> Makefile:3601: update target 'protoc' due to: >> google/protobuf/compiler/main.o libprotobuf.la libprotoc.la >> rm -f protoc >> /bin/bash ../libtool --tag=CXX --mode=link >> riscv64-unknown-linux-gnu-g++ -pthread -DHAVE_PTHREAD=1 -Wall >> -Wno-sign-compare -O2 -g -DNDEBUG -pthread -o protoc >> google/protobuf/compiler/main.o -lpthread libprotobuf.la libprotoc.la >> libtool: link: riscv64-unknown-linux-gnu-g++ -pthread -DHAVE_PTHREAD=1 >> -Wall -Wno-sign-compare -O2 -g -DNDEBUG -pthread -o .libs/protoc >> google/protobuf/compiler/main.o -lpthread ./.libs/libprotobuf.so >> ./.libs/libprotoc.so -pthread -Wl,-rpath >> -Wl,/home/jerry/Documents/drive/Projects/protobuf/build/lib >> ./.libs/libprotobuf.so: undefined reference to >> `google::protobuf::internal::Release_CompareAndSwap(long volatile*, long, >> long)' >> collect2: error: ld returned 1 exit status >> Makefile:3601: recipe for target 'protoc' failed >> make[3]: *** [protoc] Error 1 >> make[3]: Leaving directory >> '/home/jerry/Documents/drive/Projects/protobuf/src' >> Makefile:2106: recipe for target 'all' failed >> make[2]: *** [all] Error 2 >> make[2]: Leaving directory >> '/home/jerry/Documents/drive/Projects/protobuf/src' >> Makefile:1555: recipe for target 'all-recursive' failed >> make[1]: *** [all-recursive] Error 1 >> make[1]: Leaving directory '/home/jerry/Documents/drive/Projects/protobuf' >> Makefile:1462: recipe for target 'all' failed >> make: *** [all] Error 2 >> >> >> >> >> I'm not sure why this is happening? libprotobuf should have compiled with >> the atomic functions defined in >> src/google/protobuf/stubs/atomicops_internals_generic_gcc.h. Why would >> there be a linking error here? >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/protobuf. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
