loop_apply.o: file not recognized: File format not recognized
Asked Answered
R

2

4

I am trying to install R’s plyr package. Here is the error message:

* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
clang++  -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -I/opt/boost_1_61_0/boost -c RcppExports.cpp -o RcppExports.o
clang -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/cd/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -g -O2 -flto -c loop_apply.c -o loop_apply.o
clang++  -I/opt/R-3.4.1/include -DNDEBUG  -I"/home/isomorphismes/R/i686-pc-linux-gnu-library/3.4/Rcpp/include" -I/usr/local/include   -fpic  -I/opt/boost_1_61_0/boost -c split-numeric.cpp -o split-numeric.o
clang++ -shared -L/usr/local/lib -o plyr.so RcppExports.o loop_apply.o split-numeric.o
loop_apply.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/opt/R-3.4.1/share/make/shlib.mk:6: recipe for target 'plyr.so' failed
make: *** [plyr.so] Error 1
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/cd/R/i686-pc-linux-gnu-library/3.4/plyr’

The *.o files are in /opt/plyr/src, from github.com/hadley/plyr. They look like this on my system:

i@scheherezade:/opt/plyr/src$ file *o
loop_apply.o:    LLVM IR bitcode
RcppExports.o:   ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
split-numeric.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
Rosaceous answered 6/9, 2017 at 21:15 Comment(0)
A
2

In case you didn't know, -flto specifies link time optimization, and has been added by R. How did you manage to end up with such a mis-configured R install?

Adding -flto to the link command may work? Or remove it from the loop_apply compilation line. If either of those works, you need to fix your R install.

Alizaalizarin answered 7/9, 2017 at 5:23 Comment(5)
Hah. By ignoring @TonyFischetti's advice here: onthelambda.com/2013/11/22/… Thanks, DaBookshah.Rosaceous
I’m not sure how to change the install pocess (like changing the compilation lines or the linker), but compiling without ./configure --enable-lto. I guess this question provides an answer to stackoverflow.com/questions/23736507/… ?Rosaceous
*but compiling without ./configure --enable-lto solved it.Rosaceous
For future reference, you can change the package install process by editing the Makeconf file. On windows it's under <R install dir>/etc/x64/Makeconf. On other platforms it will be somewhere similar. Although editing this file would probably not be the recommended way of solving the problem you gave here.Alizaalizarin
Thanks, @DaBookshah!Rosaceous
E
0

Compiling with -flto using clang requires (on Ubuntu) installing the llvm-dev package. Otherwise, the linker is unable to handle -flto object files.

apt-get install clang-10 llvm-10-dev

Now the linking should succeed.

Epner answered 19/8, 2020 at 11:8 Comment(2)
Okay, what if the link usually works, but spontaneously fails with that error occasionally, and make -B makes it magically work okay again. Can't be clang-dev package, right? This crap is still happening in clang 17.Mariselamarish
Occasionally failing make builds are (in my experience) normally caused by wrong parallelism (command runs before its inputs are ready) or by multiple commands generating the same output (each differently) so build succeeds only if the right command runs last. Try running the build with VERBOSE=1 and examine the object file with objdump -h if it contains the LTO sections, maybe? (gcc.gnu.org/onlinedocs/gccint/LTO-object-file-layout.html)Epner

© 2022 - 2024 — McMap. All rights reserved.