I'm reading the open-source code for RBENV, and I came across this line of code. When I generated the Makefile using the configure
script and ran make
, I saw the following:
$ make
gcc -fno-common -c -o realpath.o realpath.c
gcc -dynamiclib -dynamic -undefined dynamic_lookup -o ../libexec/rbenv-realpath.dylib realpath.o
I wanted to know what each of these commands is doing, so I started Googling each of the flags. I found many of them, but -undefined dynamic_lookup
initially stumped me. Eventually I found this Github issue, which contained the following sentence:
...the option -undefined dynamic_lookup must be passed to the linker to indicate that unresolved symbols will be resolved at runtime.
This makes sense to me, given what I know about the purpose of this particular Makefile (it allows RBENV to use a faster, more performant version of the realpath
program as a dynamic library).
However, I was unable to confirm this independently, since I don't see any official GCC docs which describe the -undefined
flag or the dynamic_lookup
option. I Googled gcc dynamic_lookup site:gnu.org
, but the only results which turned up were Bugzilla tickets, email threads about patches, etc. I also searched man gcc
and help gcc
in my terminal, but got No manual entry for gcc
as a response.
Questions:
- Is the Github issue's description of
-undefined dynamic_lookup
correct? - Am I going crazy, or is
-undefined dynamic_lookup
actually missing from the gcc docs?