From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 2 21:51:17 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F177106564A for ; Fri, 2 Jul 2010 21:51:17 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 291258FC16 for ; Fri, 2 Jul 2010 21:51:16 +0000 (UTC) Received: by iwn35 with SMTP id 35so1717766iwn.13 for ; Fri, 02 Jul 2010 14:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=2LGtRDDOttbBMdLxrWO5eWXlvqSqkPQNgeVxrBsbfJc=; b=MLylhwo0a98NYsAoVq4hBrJQ+gAWbK1qma9R99Ag8a/ldbcSLFIYGwLJaIApjnziGJ cY/ziIKZFEU3q6cp00JoREfa1LoKa7HdSkwMcCahHOTQGIVRbsDVQ69+EId+Q5H6GAZc 6OzKkQ648TVUSTrwf/KhxaRyOnpRPqHcCWil4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ccGVLEQybWjjErcqZ4qkkmhSIvvp+OF066HNhJgcuvOHzssCQQVoCusAg+XULygWN7 QF9HM3I5eoqVxrcxh2yLqPWoD770ntsoFjLcquZ930MCkcYYv0HWLRRBZN+nhdBcQLhO xeIMyx4m84hz9X1nruCeKYkJqpfrEj2pCeTWI= MIME-Version: 1.0 Received: by 10.42.6.75 with SMTP id 11mr462397icz.38.1278107476266; Fri, 02 Jul 2010 14:51:16 -0700 (PDT) Received: by 10.42.5.78 with HTTP; Fri, 2 Jul 2010 14:51:16 -0700 (PDT) Date: Fri, 2 Jul 2010 14:51:16 -0700 Message-ID: From: Matthew Fleming To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Using lex in a shared library X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2010 21:51:17 -0000 I have the following Makefile for a shared library at $work: ISI_TOP= ../.. LIB= isi_date SHLIB_MAJOR= 1 SHLIB_MINOR= 0 SRCS= date.c date_parser.new.c lex.yy.c INCS= date.h INCLUDEDIR= /usr/include/isi_date YFLAGS+= -vt FLEX= /usr/bin/flex LDADD= -ll CLEANFILES+= date_parser.new.c y.tab.h y.tab.c lex.yy.c y.output \ check_date.log test lex.yy.c: date_lexer.new.l ${FLEX} $> CFLAGS+= -I${.CURDIR} #CFLAGS+= -g .include "${ISI_TOP}/isi.lib.mk" This builds fine as on i386. I'm trying to get all our user-space to be 64-bit clean, and I run into an error when building on amd64: /data/sb/BR_MDF_64CLEAN/obj/data/sb/BR_MDF_64CLEAN/src/tmp/usr/bin/ld: /data/sb/BR_MDF_64CLEAN/obj/data/sb/BR_MDF_64CLEAN/src/tmp/usr/lib/libl.a(libyywrap.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC /data/sb/BR_MDF_64CLEAN/obj/data/sb/BR_MDF_64CLEAN/src/tmp/usr/lib/libl.a: could not read symbols: Bad value The following diff makes the compile work, but I have no idea (yet) whether this will run, if it's the right solution, etc. Index: usr.bin/lex/lib/Makefile =================================================================== --- usr.bin/lex/lib/Makefile (revision 153343) +++ usr.bin/lex/lib/Makefile (working copy) @@ -4,11 +4,16 @@ LIB= ln SRCS= libmain.c libyywrap.c -NO_PIC= +#NO_PIC= +SHLIB_MAJOR= 1 +SHLIB_MINOR= 0 + .if ${MK_INSTALLLIB} != "no" LINKS= ${LIBDIR}/libln.a ${LIBDIR}/libl.a LINKS+= ${LIBDIR}/libln.a ${LIBDIR}/libfl.a +LINKS+= ${LIBDIR}/libln.so ${LIBDIR}/libl.so +LINKS+= ${LIBDIR}/libln${LIB_SUFFIX}.so ${LIBDIR}/libl${LIB_SUFFIX}.so .endif .if ${MK_PROFILE} != "no" Thanks, matthew