dtc build failures on OS X
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies. First, it says this:
LD libfdt/libfdt.so
ld: unknown option: --version-script=libfdt/version.lds
collect2: ld returned 1 exit status
A Google search suggested that I can just delete the --version-script option. I did that, and now I get this error:
LD libfdt/libfdt.so
ld: unknown option: -soname
collect2: ld returned 1 exit status
This web page: http://lists.apple.com/archives/unix-porting/2003/Oct/msg00032.html
had some suggestions on how to fix that, so my Makefile now looks like this:
$(LIBFDT_lib):
@$(VECHO) LD $@
$(CC) $(LDFLAGS) -fPIC -Wl,-dylib_install_name -Wl,$(notdir
$@) -shared -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).so $^
ln -s libfdt-$(DTC_VERSION).so $(LIBFDT_objdir)/libfdt.soBut now I get this error:
LD libfdt/libfdt.so
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
So now I'm stuck. Has anyone tried this before? Can anyone tell me how to fix this?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
A message that is not in the archive (sent off-list or not yet received): ed82fe3e0905191908v8c5fcdft953c4e1ba7969f2a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 2 lines · Timur Tabi
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies. First, it says this:
Well, I'm not surprised something has gone wrong - not much work has gone into making dtc portable yet (though it has been compiled on FreeBSD, at least).
Quoted 6 lines
LD libfdt/libfdt.so
ld: unknown option: --version-script=libfdt/version.lds
collect2: ld returned 1 exit statusA Google search suggested that I can just delete the --version-script option. I did that, and now I get this error:
Hrm. What toolchain are you using?
Quoted 14 lines
LD libfdt/libfdt.so
ld: unknown option: -soname
collect2: ld returned 1 exit statusThis web page: http://lists.apple.com/archives/unix-porting/2003/Oct/msg00032.html
had some suggestions on how to fix that, so myMakefilenow looks like this:$(LIBFDT_lib):
@$(VECHO) LD $@ $(CC) $(LDFLAGS) -fPIC -Wl,-dylib_install_name -Wl,$(notdir $@) -shared -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).so $^ ln -s libfdt-$(DTC_VERSION).so $(LIBFDT_objdir)/libfdt.so
Quoted 8 lines
But now I get this error:
LD libfdt/libfdt.so
Undefined symbols:
"_main", referenced from:start in crt1.10.5.old: symbol(s) not found
collect2: ld returned 1 exit status
*That* looks like it's trying to build an executable, rather than a shared library. Hence including the crt1.o module, which wants to call main().
Quoted 2 lines
So now I'm stuck. Has anyone tried this before? Can anyone tell me how to fix this?
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 29 lines · Timur Tabi
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies. First, it says this:
LD libfdt/libfdt.so
ld: unknown option: --version-script=libfdt/version.lds
collect2: ld returned 1 exit statusA Google search suggested that I can just delete the --version-script option. I did that, and now I get this error:
LD libfdt/libfdt.so
ld: unknown option: -soname
collect2: ld returned 1 exit statusThis web page: http://lists.apple.com/archives/unix-porting/2003/Oct/msg00032.html
had some suggestions on how to fix that, so myMakefilenow looks like this:$(LIBFDT_lib):
@$(VECHO) LD $@ $(CC) $(LDFLAGS) -fPIC -Wl,-dylib_install_name -Wl,$(notdir $@) -shared -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).so $^ ln -s libfdt-$(DTC_VERSION).so $(LIBFDT_objdir)/libfdt.soBut now I get this error:
LD libfdt/libfdt.so
Undefined symbols:
"_main", referenced from:
Quoted 6 lines
start in crt1.10.5.old: symbol(s) not found
collect2: ld returned 1 exit statusSo now I'm stuck. Has anyone tried this before? Can anyone tell me how to fix this?
-shared is incorrect on mac os it's -dynamiclib
see attached patch
Best Regards,
J.
Quoted 1 line
From
37a2ddc183fa381cc025adf8e9d9d143029fe159Mon Sep 17 00:00:00 2001
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj-sclMFOaUSTBWk0Htik3J/[email protected]>
Date: Wed, 20 May 2009 09:50:31 +0200
Subject: [PATCH] add Mac OS X support
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-script
to buid on it do
make OSX=y
--- Makefile | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
Makefile +11 -3
@@ -28,6 +28,14 @@ BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib INCLUDEDIR = $(PREFIX)/include +ifdef OSX +SHAREDLIB_EXT=dylib +SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl, +else +SHAREDLIB_EXT=so +SHAREDLIB_LINK_OPTIONS=-shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname, +endif + # # Overall rules #
@@ -116,7 +124,7 @@ endif LIBFDT_objdir = libfdt LIBFDT_srcdir = libfdt LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a -LIBFDT_lib = $(LIBFDT_objdir)/libfdt.so +LIBFDT_lib = $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT) LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
@@ -220,8 +228,8 @@ clean: libfdt_clean tests_clean $(LIBFDT_lib): @$(VECHO) LD $@ - $(CC) $(LDFLAGS) -fPIC -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,$(notdir $@) -shared -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).so $^ - ln -s libfdt-$(DTC_VERSION).so $(LIBFDT_objdir)/libfdt.so + $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(notdir $@) -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $^ + ln -sf libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT) %.lex.c: %.l @$(VECHO) LEX $@
Signature · 1 line
1.6.0.4
_______________________________________________
devicetree-discuss mailing list [email protected]
https://ozlabs.org/mailman/listinfo/devicetree-discuss
A message that is not in the archive (sent off-list or not yet received): 20090520074611.GW17539-RQcB7r2h9QmfDR2tN2SG5Ni2O/[email protected]
Timur Tabi
Acked-byQuoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD
-shared is incorrect on mac os it's -dynamiclib
see attached patch
It would be nice if it auto-detected OS X, but I'm glad it works. Thanks.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
A message that is not in the archive (sent off-list or not yet received): ed82fe3e0905252037r574e56ecjd8689b800c74561f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PATCH v2 1/1 add Mac OS X support
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-script
add HOSTOS macro to detect the current os you are
---
V2
detect dynamicly the host OS
Makefile | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-)
Makefile +14 -3
@@ -28,6 +28,17 @@ BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib INCLUDEDIR = $(PREFIX)/include +HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ + sed -e 's/\(cygwin\).*/cygwin/') + +ifeq ($(HOSTOS),darwin) +SHAREDLIB_EXT=dylib +SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl, +else +SHAREDLIB_EXT=so +SHAREDLIB_LINK_OPTIONS=-shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname, +endif + # # Overall rules #
@@ -116,7 +127,7 @@ endif LIBFDT_objdir = libfdt LIBFDT_srcdir = libfdt LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a -LIBFDT_lib = $(LIBFDT_objdir)/libfdt.so +LIBFDT_lib = $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT) LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
@@ -220,8 +231,8 @@ clean: libfdt_clean tests_clean $(LIBFDT_lib): @$(VECHO) LD $@ - $(CC) $(LDFLAGS) -fPIC -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,$(notdir $@) -shared -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).so $^ - ln -s libfdt-$(DTC_VERSION).so $(LIBFDT_objdir)/libfdt.so + $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(notdir $@) -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $^ + ln -sf libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT) %.lex.c: %.l @$(VECHO) LEX $@
Signature · 1 line
1.6.0.4
A message that is not in the archive (sent off-list or not yet received): 1243361246-1743-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/[email protected]
Timur Tabi
Acked-byRe: [PATCH V2] add Mac OS X support
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-scriptadd HOSTOS macro to detect the current os you are
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Re: [PATCH V2] add Mac OS X support
In reply to a message not in the archiveQuoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-scriptadd HOSTOS macro to detect the current os you are
---
jdl do you have any plan to apply it?
Best Regards,
J.
A message that is not in the archive (sent off-list or not yet received): 20090613192148.GN25406-RQcB7r2h9QmfDR2tN2SG5Ni2O/[email protected]
Re: [PATCH V2] add Mac OS X support
Jon, are you still updating dtc.git?
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-scriptadd HOSTOS macro to detect the current os you are
---
jdl do you have any plan to apply it?
Best Regards,
J.
_______________________________________________
devicetree-discuss mailing list [email protected]
https://ozlabs.org/mailman/listinfo/devicetree-discuss
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
A message that is not in the archive (sent off-list or not yet received): ed82fe3e0907151026w4c957398s63ce7d8dae7c5460-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH V2] add Mac OS X support
Quoted 1 line
Jon, are you still updating dtc.git?
Yep.
jdl
A message that is not in the archive (sent off-list or not yet received): E1MRF4Z-0005vL-Hl-CYoMK+44s/[email protected]
Re: [PATCH V2] add Mac OS X support
Quoted 3 lines · Jon Loeliger
Quoted 1 line
Jon, are you still updating dtc.git?
Yep.
Then would you be so kind as to apply my patch, if you have no objections?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Re: [PATCH V2] add Mac OS X support
In reply to a message not in the archiveQuoted 11 lines
use dylib shared lib extention
allow to specifiy os specific shared lib link option
Mac OS use -dynamiclib instead of -shared, -install_name instead of -soname and does not support --version-scriptadd HOSTOS macro to detect the current os you are
---
V2
detect dynamicly the host OS
Applied and pushed out.
Thanks,
jdl
Quoted 2 lines
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies.
It doesn't die, it just complains ;-)
You're trying to build a Linux shared library on OSX. This won't work. Not only are the command line options not the same, the semantics are totally different as well; importantly, the versioning mechanism is very different. Given that, you do not want to use a shared library at all -- just use a normal (static) library. IMNSHO that should be the default, on Linux as well...
Segher
A message that is not in the archive (sent off-list or not yet received): C44AFDDE-9BB1-4914-8B26-5816D83B909A-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org
Quoted 11 lines · Segher Boessenkool
Quoted 2 lines
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies.
It doesn't die, it just complains ;-)
You're trying to build a Linux shared library on OSX. This won't work. Not only are the command line options not the same, the semantics are totally different as well; importantly, the versioning mechanism is very different. Given that, you do not want to use a shared library at all -- just use a normal (static) library. IMNSHO that should be the default, on Linux as well...
It was, originally, but someone wanted a shared lib.
Actually, the current Makefile builds both, by default.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies.
It doesn't die, it just complains ;-)
Quoted 8 lines
Quoted 6 lines
You're trying to build a Linux shared library on OSX. This won't work. Not only are the command line options not the same, the semantics are totally different as well; importantly, the versioning mechanism is very different. Given that, you do not want to use a shared library at all -- just use a normal (static) library. IMNSHO that should be the default, on Linux as well...
It was, originally, but someone wanted a shared lib.
And you decided to take on all that maintenance pain? You're too good for this world. Or gullible, heh.
Quoted 1 line
Actually, the current
Makefilebuilds both, by default.
It shouldn't try to build Linux shared objects unless you are building a Linux target; easiest would be to just never build the shared library by default. Your choice :-)
Segher
A message that is not in the archive (sent off-list or not yet received): 82CF1AB0-22C1-4C33-B6E1-B8816AF2E094-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org
Quoted 12 lines · Segher Boessenkool
Quoted 12 lines
Quoted 11 lines
Quoted 2 lines
I'm trying to build dtc on Mac OS X. The compilation seems to go okay, but the linker dies.
It doesn't die, it just complains ;-)
You're trying to build a Linux shared library on OSX. This won't work. Not only are the command line options not the same, the semantics are totally different as well; importantly, the versioning mechanism is very different. Given that, you do not want to use a shared library at all -- just use a normal (static) library. IMNSHO that should be the default, on Linux as well...
Quoted 4 lines
Quoted 1 line
It was, originally, but someone wanted a shared lib.
And you decided to take on all that maintenance pain? You're too good for this world. Or gullible, heh.
Something like that.
Quoted 5 lines
Quoted 1 line
Actually, the current
Makefilebuilds both, by default.It shouldn't try to build Linux shared objects unless you are building a Linux target; easiest would be to just never build the shared library by default. Your choice :-)
Well, to be fair, the current rule should be right, or close to it, for most ELF systems, not just Linux.
Actually, another issue with this is that currently we build all the libfdt objects with -fPIC, which significantly increases their size. That tends to frighten people who are looking at building libfdt into their firmware.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson