Subj : OSX Build Issue w/ libjs.so To : netscape.public.mozilla.jseng From : Sajid Raza Date : Thu May 27 2004 07:00 pm This is a multi-part message in MIME format. --------------070401010600070409020400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Well, my case, may be very specific, its working but I thought it might be worth sharing: Basically, I'm using loading libraries into Apache, SpiderMonkey's libjso.so is one of them. Everything works perfectly on Linux/X86. On Mac OSX, the shared library builds fine, but loading it into Apache generates: libjs.so (not a Mach-O file, bad magic number) From a bit of Googling it seems I need to do two things, the first of which seems dubious: Build all source with -fno-common From OSX libtool man page: "Dynamically linked libraries have two restrictions: No symbol may be defined in more than one object file and no common symbol can be used." Since the OSX libtool's a little different run (static is the default): libtool -dynamic -framework System -o Darwin_DBG.OBJ/libjs.so Darwin_DBG.OBJ/jsapi.o Darwin_DBG.OBJ/jsarena.o Darwin_DBG.OBJ/jsarray.o Darwin_DBG.OBJ/jsatom.o Darwin_DBG.OBJ/jsbool.o Darwin_DBG.OBJ/jscntxt.o Darwin_DBG.OBJ/jsdate.o Darwin_DBG.OBJ/jsdbgapi.o Darwin_DBG.OBJ/jsdhash.o Darwin_DBG.OBJ/jsdtoa.o Darwin_DBG.OBJ/jsemit.o Darwin_DBG.OBJ/jsexn.o Darwin_DBG.OBJ/jsfun.o Darwin_DBG.OBJ/jsgc.o Darwin_DBG.OBJ/jshash.o Darwin_DBG.OBJ/jsinterp.o Darwin_DBG.OBJ/jslock.o Darwin_DBG.OBJ/jslog2.o Darwin_DBG.OBJ/jslong.o Darwin_DBG.OBJ/jsmath.o Darwin_DBG.OBJ/jsnum.o Darwin_DBG.OBJ/jsobj.o Darwin_DBG.OBJ/jsopcode.o Darwin_DBG.OBJ/jsparse.o Darwin_DBG.OBJ/jsprf.o Darwin_DBG.OBJ/jsregexp.o Darwin_DBG.OBJ/jsscan.o Darwin_DBG.OBJ/jsscope.o Darwin_DBG.OBJ/jsscript.o Darwin_DBG.OBJ/jsstr.o Darwin_DBG.OBJ/jsutil.o Darwin_DBG.OBJ/jsxdrapi.o Darwin_DBG.OBJ/prmjtime.o -Lfdlibm/Darwin_DBG.OBJ -lfdm -lgcc The difference being the switch -dynamic, and -lgcc. When I tried manually linking against the libjs.so generated by the original config scripts, I received errors. My modified Darwin.mk is attached. -S --------------070401010600070409020400 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="Darwin.mk" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Darwin.mk" # -*- Mode: makefile -*- # # The contents of this file are subject to the Netscape Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.mozilla.org/NPL/ # # Software distributed under the License is distributed on an "AS # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # implied. See the License for the specific language governing # rights and limitations under the License. # # The Original Code is Mozilla Communicator client code, released # March 31, 1998. # # The Initial Developer of the Original Code is Netscape # Communications Corporation. Portions created by Netscape are # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # # Contributor(s): # # Steve Zellers (zellers@apple.com) # # Alternatively, the contents of this file may be used under the # terms of the GNU Public License (the "GPL"), in which case the # provisions of the GPL are applicable instead of those above. # If you wish to allow use of your version of this file only # under the terms of the GPL and not to allow others to use your # version of this file under the NPL, indicate your decision by # deleting the provisions above and replace them with the notice # and other provisions required by the GPL. If you do not delete # the provisions above, a recipient may use your version of this # file under either the NPL or the GPL. # # # Config for Mac OS X as of PR3 # Just ripped from Linux config # CC = cc CCC = g++ CFLAGS += -Wall -Wno-format -fno-common OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DDARWIN RANLIB = ranlib MKSHLIB = libtool -dynamic $(XMKSHLIBOPTS) -framework System -lgcc #.c.o: # $(CC) -c -MD $*.d $(CFLAGS) $< CPU_ARCH = $(shell uname -m) ifeq (86,$(findstring 86,$(CPU_ARCH))) CPU_ARCH = x86 OS_CFLAGS+= -DX86_LINUX endif GFX_ARCH = x OS_LIBS = -lc -framework System ASFLAGS += -x assembler-with-cpp ifeq ($(CPU_ARCH),alpha) # Ask the C compiler on alpha linux to let us work with denormalized # double values, which are required by the ECMA spec. OS_CFLAGS += -mieee endif # Use the editline library to provide line-editing support. JS_EDITLINE = 1 # Don't allow Makefile.ref to use libmath NO_LIBM = 1 --------------070401010600070409020400-- .