Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a switch on macOS fails due to ranlib #3749

Closed
ghost opened this issue Feb 12, 2019 · 10 comments
Closed

Creating a switch on macOS fails due to ranlib #3749

ghost opened this issue Feb 12, 2019 · 10 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2019

I am currently trying to install a new switch besides my default system one but am getting a failure during compilation that seems to be related to ranlib. I am quite new to the ecosystem, so please forgive me if this issue is easily solved or just me misusing the tool.

My configuration:

# opam config report
# opam-version      2.0.1 
# self-upgrade      no
# system            arch=x86_64 os=macos os-distribution=homebrew os-version=10.14.3
# solver            builtin-mccs+glpk
# install-criteria  -removed,-count[version-lag,request],-count[version-lag,changed],-changed
# upgrade-criteria  -removed,-count[version-lag,solution],-new
# jobs              7
# repositories      1 (http) (default repo at cbd68e57)
# pinned            0
# current-switch    default

Here’s the log created when trying to create the switch:

$ opam switch create 4.06.1 -v
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
[ocaml-base-compiler.4.06.1] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
+ /Users/robert/.opam/opam-init/hooks/sandbox.sh "build" "./configure" "-prefix" "/Users/robert/.opam/4.06.1" "-with-debug-runtime" "-cc" "cc" "-aspp" "cc -c" (CWD=/Users/robert/.opam/4.06.1/.opam-switch/build/ocaml-base-compiler.4.06.1)
- Configuring OCaml version 4.06.1
- Configuring for host x86_64-apple-darwin18.2.0 ...
- Configuring for target x86_64-apple-darwin18.2.0 ...
- Using compiler cc.
- Compiler family and version: clang-10-0.
- The C compiler is ISO C99 compliant.
- Checking the sizes of integers and pointers...
- Wow! A 64 bit architecture!
- This is a little-endian architecture.
- Doubles can be word-aligned.
- 64-bit integers can be word-aligned.
- ranlib found
- #! appears to work in shell scripts.
- POSIX signal handling found.
- expm1(), log1p(), hypot(), copysign() found.
- getrusage() found.
- times() found.
- issetugid() found.
- termcap functions found (with libraries '-lcurses')
- You have BSD sockets.
- socklen_t is defined in <sys/socket.h>
- inet_aton() found.
- IPv6 is supported.
- stdint.h found.
- unistd.h found.
- off_t is defined in <sys/types.h>
- dirent.h found.
- rewinddir() found.
- lockf() found.
- mkfifo() found.
- getcwd() found.
- getpriority() found.
- utime() found.
- utimes() found.
- dup2() found.
- fchmod() found.
- truncate() found.
- sys/select.h found.
- select() found.
- nanosleep() found.
- symlink() found.
- waitpid() found.
- wait4() found.
- getgroups() found.
- setgroups() found.
- initgroups() found.
- POSIX termios found.
- Asynchronous I/O are supported.
- setitimer() found.
- gethostname() found.
- uname() found.
- gettimeofday() found.
- mktime() found.
- setsid() found.
- putenv() found.
- setlocale() and <locale.h> found.
- dlopen() found.
- Dynamic loading of shared libraries is supported.
- mmap() found.
- pwrite() found
- stat() supports nanosecond precision.
- mkstemp() found
- nice() found
- sys/shm.h found.
- Replay debugger supported.
- System stack overflow can be detected.
- POSIX threads library supported.
- Options for linking with POSIX threads: -lpthread
- sigwait() found
- Bytecode threads library supported.
- X11 works
- Options for compiling for X11: -I/opt/local/include
- Options for linking with X11: -L/opt/local/lib -lX11
- [WARNING] BFD library not found, 'objinfo' will be unable to display info  on .cmxs files.
- Assembler supports CFI
- 
- ** Configuration summary **
- 
- Directories where OCaml will be installed:
-         binaries.................. /Users/robert/.opam/4.06.1/bin
-         standard library.......... /Users/robert/.opam/4.06.1/lib/ocaml
-         manual pages.............. /Users/robert/.opam/4.06.1/man (with extension .1)
- Configuration for the bytecode compiler:
-         C compiler used........... cc
-         options for compiling.....  -O2 -fno-strict-aliasing -fwrapv
-         options for linking.......     -lcurses -lpthread
-         shared libraries are supported
-         options for compiling.....   -O2 -fno-strict-aliasing -fwrapv
-         command for building...... cc -shared -flat_namespace -undefined suppress                    -Wl,-no_compact_unwind -o lib.so /a/path objs
- Configuration for the native-code compiler:
-         hardware architecture..... amd64
-         OS variant................ macosx
-         C compiler used........... cc
-         options for compiling.....  -O2 -fno-strict-aliasing -fwrapv
-         options for linking.......  
-         assembler ................ clang -arch x86_64 -Wno-trigraphs -c
-         preprocessed assembler ... cc -c
-         assembler supports CFI ... yes
-         with frame pointers....... no
-         naked pointers forbidden.. no
-         spacetime profiling....... no
-         reserved bits in header... no
-         C plugins................. no
-         compile with -fPIC........ no
-         native dynlink ........... true
-         profiling with gprof ..... supported
-         using flambda middle-end . no
-         force safe strings ............. no
-         (-safe-string is the default per-file option)
-         flat float arrays ........ yes
-         afl-fuzz always enabled .. no
- Source-level replay debugger: supported
- Debug runtime will be compiled and installed
- Additional libraries supported:
-         unix str dynlink bigarray raw_spacetime_lib systhreads threads graph
- Configuration for the "graph" library:
-         options for compiling .... -I/opt/local/include
-         options for linking ...... -L/opt/local/lib -lX11
- 
- ** OCaml configuration completed successfully **
- 
+ /Users/robert/.opam/opam-init/hooks/sandbox.sh "build" "make" "world" (CWD=/Users/robert/.opam/4.06.1/.opam-switch/build/ocaml-base-compiler.4.06.1)
- /Applications/Xcode.app/Contents/Developer/usr/bin/make -C byterun  all
- echo "/Users/robert/.opam/4.06.1/lib/ocaml/stublibs" > ld.conf
- echo "/Users/robert/.opam/4.06.1/lib/ocaml" >> ld.conf
- sed -n -e '/^  /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
- 	       -e '/^}/q' caml/instruct.h > caml/jumptbl.h
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  interp.c
- ../tools/make-version-header.sh ../VERSION > caml/version.h
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  misc.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  stacks.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  fix_code.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  startup_aux.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  startup.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  freelist.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  major_gc.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  minor_gc.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  memory.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  alloc.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  roots.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  globroots.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  fail.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  signals.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  signals_byt.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  printexc.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  backtrace_prim.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  backtrace.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  compare.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  ints.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  floats.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  str.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  array.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  io.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  extern.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  intern.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  hash.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  sys.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  meta.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  parsing.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  gc_ctrl.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  terminfo.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  md5.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  obj.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  lexing.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  callback.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  debugger.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  weak.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  compact.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  finalise.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  custom.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  dynlink.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  spacetime.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  afl.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  unix.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  bigarray.c
- cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  main.c
- ar rc libcamlrun.a  interp.o misc.o stacks.o fix_code.o startup_aux.o startup.o freelist.o major_gc.o minor_gc.o memory.o alloc.o roots.o globroots.o fail.o signals.o signals_byt.o printexc.o backtrace_prim.o backtrace.o compare.o ints.o floats.o str.o array.o io.o extern.o intern.o hash.o sys.o meta.o parsing.o gc_ctrl.o terminfo.o md5.o obj.o lexing.o callback.o debugger.o weak.o compact.o finalise.o custom.o dynlink.o spacetime.o afl.o unix.o bigarray.o main.o; ranlib libcamlrun.a
- /opt/local/bin/ranlib: object: libcamlrun.a(interp.o) malformed object (unknown load command 1)
- ar: internal ranlib command failed
- ranlib: object: libcamlrun.a(interp.o) malformed object (unknown load command 1)
- make[1]: *** [libcamlrun.a] Error 1
- make: *** [coldstart] Error 2
[ERROR] The compilation of ocaml-base-compiler failed at "/Users/robert/.opam/opam-init/hooks/sandbox.sh build make world".

#=== ERROR while compiling ocaml-base-compiler.4.06.1 =========================#
# context     2.0.1 | macos/x86_64 |  | https://opam.ocaml.org#cbd68e57
# path        ~/.opam/4.06.1/.opam-switch/build/ocaml-base-compiler.4.06.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build make world
# exit-code   2
# env-file    ~/.opam/log/ocaml-base-compiler-27030-05296d.env
# output-file ~/.opam/log/ocaml-base-compiler-27030-05296d.out
### output ###
# [...]
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  dynlink.c
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  spacetime.c
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  afl.c
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  unix.c
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  bigarray.c
# cc -c -O2 -fno-strict-aliasing -fwrapv -Wall  -g -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  main.c
# ar rc libcamlrun.a  interp.o misc.o stacks.o fix_code.o startup_aux.o startup.o freelist.o major_gc.o minor_gc.o memory.o alloc.o roots.o globroots.o fail.o signals.o signals_byt.o printexc.o backtrace_prim.o backtrace.o compare.o ints.o floats.o str.o array.o io.o extern.o intern.o hash.o sys.o meta.o parsing.o gc_ctrl.o terminfo.o md5.o obj.o lexing.o callback.o debugger.o weak.o compact.o [...]
# /opt/local/bin/ranlib: object: libcamlrun.a(interp.o) malformed object (unknown load command 1)
# ar: internal ranlib command failed
# ranlib: object: libcamlrun.a(interp.o) malformed object (unknown load command 1)
# make[1]: *** [libcamlrun.a] Error 1
# make: *** [coldstart] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
┌─ The following actions were aborted
│ ∗ install ocaml        4.06.1
│ ∗ install ocaml-config 1
└─ 
┌─ The following actions failed
│ λ build ocaml-base-compiler 4.06.1
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads  base
│ ∗ install base-unix     base
└─ 
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
'opam switch create 4.06.1 -v' failed.
@rjbou
Copy link
Collaborator

rjbou commented Feb 18, 2019

Your issue seems similar to #3650 (linker problem on macos), you can try solutions proposed there (unlink binutils).

Thanks for reporting!

@ghost
Copy link
Author

ghost commented Feb 18, 2019

Hi @rjbou thanks for you reply! I had seen that issue previously and tried to apply the proposed solution but I have not installed binutils via Homebrew (so unlinking is not possible).

If there is any data about my environment I can provide to make resolving this easier, please just let me know.

@rjbou
Copy link
Collaborator

rjbou commented Feb 19, 2019

I see from the working directory that you are using XCode, ranlib malformed object can result from a mismatching cli. Is it your case ?

@ghost
Copy link
Author

ghost commented Feb 20, 2019

Both my Xcode and Xcode Command Line Tools are up-to-date and matched:

$ brew config
HOMEBREW_VERSION: 1.8.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2063a8a4d849b00f279ee2dd26e9f38745382ffc
Last commit: 3 months ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 088bd85c3bd95ccf851d8ac7f4846a0e690a433f
Core tap last commit: 3 months ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.19.1 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 10.0.1, 1.8.0_191, 1.8.0_66, 1.7.0_79
macOS: 10.14.3-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
XQuartz: 2.7.11 => /opt/X11

@rjbou
Copy link
Collaborator

rjbou commented Feb 20, 2019

@avsm @mseri , any idea ?

@dbuenzli
Copy link
Contributor

/opt/local/bin/ranlib

This is a bit strange here I have:

> command -v ranlib
/usr/bin/ranlib

There may be a problem along the lines where you are using xcode's dev tools to build the compiler but a ranlib provided by homebrew which may not be compatible with it. Could you maybe check which package actually added that ranlib and maybe brew unlink it to see if it works.

@ghost
Copy link
Author

ghost commented Feb 20, 2019

Hey @dbuenzli thanks a lot for your help! Indeed, the incorrect location of ranlib seems to have been the problem - prepending /usr/bin to my $PATH allowed me to install the switch without any problems.

I'm not sure how I could have found out which package added the ranlib via homebrew, though.

@ghost ghost closed this as completed Feb 20, 2019
@dbuenzli
Copy link
Contributor

I'm not sure how I could have found out which package added the ranlib via homebrew, though.

Here's one way.

@ghost
Copy link
Author

ghost commented Feb 20, 2019

Thanks! Turns out it was libtool that was problematic.

@dbuenzli
Copy link
Contributor

dbuenzli commented Feb 20, 2019

Thanks! Turns out it was libtool that was problematic.

Aha. I think you should update/upgrade your homebrew install which is quite lagging. Here the libtool package is installed but no ranlib gets installed (only glibtool).

This should allow you to get back to your desdired $PATH order.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants