ports/127718: [patch] devel/llvm: use PIC on amd64 and add optional dependancy on Ocaml

Scot Hetzel swhetzel at gmail.com
Mon Sep 29 13:40:07 UTC 2008


>Number:         127718
>Category:       ports
>Synopsis:       [patch] devel/llvm: use PIC on amd64 and add optional dependancy on Ocaml
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 29 13:40:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Scot Hetzel
>Release:        8.0-CURRENT
>Organization:
>Environment:
FreeBSD hp010 8.0-CURRENT FreeBSD 8.0-CURRENT #8: Mon Aug 11 17:10:07 CDT 2008     root at hp010:/usr/obj/usr/src/8x/sys/DV8135NR  amd64

>Description:
Problem 1:

If the lang/ocaml port is installed, devel/llvm will build and install additional files for Ocaml support.

Problem 2:

On the www.opengtl.org download page, they show that llvm 2.3 needs to be patched and then compiled with "--enable-pic --with-pic" options on x86-64 systems.  To verify their finding, I installed and unpatched devel/llvm, and then built OpenGTL.  It failed to link due to requiring the libraries being built with these options.
>How-To-Repeat:
Problem 1:

Install lang/ocaml, then  build and install devel/llvm. Upon uninstall of these ports there will be extra files in PREFIX/lib/ocaml and PREFIX/share/doc/llvm.

Problem 2:

Install devel/llvm and then build OpenGTL (www.opengtl.org).  It will fail on FreeBSD/amd64 due to requiring PIC.
>Fix:
The attached patch contains these fixes

- add missing optional dependency on lang/ocaml
- use PIC code on FreeBSD/amd64
- add files/patch-lib_Target_X86_X86JITInfo.cpp 
  (obtained from the www.opengtl.org site)

Patch attached with submission follows:

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/devel/llvm/Makefile,v
retrieving revision 1.24
diff -u -r1.24 Makefile
--- Makefile	1 Jul 2008 20:48:43 -0000	1.24
+++ Makefile	29 Sep 2008 07:03:04 -0000
@@ -44,6 +44,27 @@
 		llvm-prof.1 llvm-ranlib.1 llvmgcc.1 \
 		llvmgxx.1 opt.1 stkrc.1 tblgen.1
 
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == "amd64"
+CONFIGURE_ARGS+=	--enable-pic --with-pic
+.endif
+
+.if exists(${LOCALBASE}/bin/ocamlc)
+WITH_OCAML=	yes
+.endif
+
+.if defined(WITH_OCAML)
+USE_OCAML=	yes
+PLIST_SUB+=	OCAML=""
+.else
+. if defined(NOPORTDOCS)
+PLIST_SUB+=	OCAML=""
+. else
+PLIST_SUB+=	OCAML="@comment "
+. endif
+.endif
+
 post-patch:
 	${REINPLACE_CMD} -e 's|\(PROJ_docsdir.*:=\).*$$|\1${DOCSDIR}|g' \
 	    ${WRKSRC}/Makefile.config.in
@@ -65,4 +86,4 @@
 regression-test: build
 	(cd ${WRKSRC}/test; ${SETENV} ${MAKE_ENV} ${GMAKE} check)
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/devel/llvm/pkg-plist,v
retrieving revision 1.12
diff -u -r1.12 pkg-plist
--- pkg-plist	1 Jul 2008 20:48:43 -0000	1.12
+++ pkg-plist	29 Sep 2008 07:32:46 -0000
@@ -331,6 +331,71 @@
 lib/libLLVMTransformUtils.a
 lib/libLLVMipa.a
 lib/libLLVMipo.a
+%%OCAML%%lib/ocaml/LLVMExecutionEngine.o
+%%OCAML%%lib/ocaml/LLVMInterpreter.o
+%%OCAML%%lib/ocaml/LLVMJIT.o
+%%OCAML%%lib/ocaml/LLVMX86.o
+%%OCAML%%lib/ocaml/libLLVMAnalysis.a
+%%OCAML%%lib/ocaml/libLLVMBitReader.a
+%%OCAML%%lib/ocaml/libLLVMBitWriter.a
+%%OCAML%%lib/ocaml/libLLVMCodeGen.a
+%%OCAML%%lib/ocaml/libLLVMCore.a
+%%OCAML%%lib/ocaml/libLLVMScalarOpts.a
+%%OCAML%%lib/ocaml/libLLVMSelectionDAG.a
+%%OCAML%%lib/ocaml/libLLVMSupport.a
+%%OCAML%%lib/ocaml/libLLVMSystem.a
+%%OCAML%%lib/ocaml/libLLVMTarget.a
+%%OCAML%%lib/ocaml/libLLVMTransformUtils.a
+%%OCAML%%lib/ocaml/libLLVMipa.a
+%%OCAML%%lib/ocaml/libllvm.a
+%%OCAML%%lib/ocaml/libllvm_analysis.a
+%%OCAML%%lib/ocaml/libllvm_bitreader.a
+%%OCAML%%lib/ocaml/libllvm_bitwriter.a
+%%OCAML%%lib/ocaml/libllvm_executionengine.a
+%%OCAML%%lib/ocaml/libllvm_scalar_opts.a
+%%OCAML%%lib/ocaml/libllvm_target.a
+%%OCAML%%lib/ocaml/llvm.a
+%%OCAML%%lib/ocaml/llvm.cma
+%%OCAML%%lib/ocaml/llvm.cmi
+%%OCAML%%lib/ocaml/llvm.cmx
+%%OCAML%%lib/ocaml/llvm.cmxa
+%%OCAML%%lib/ocaml/llvm.mli
+%%OCAML%%lib/ocaml/llvm_analysis.a
+%%OCAML%%lib/ocaml/llvm_analysis.cma
+%%OCAML%%lib/ocaml/llvm_analysis.cmi
+%%OCAML%%lib/ocaml/llvm_analysis.cmx
+%%OCAML%%lib/ocaml/llvm_analysis.cmxa
+%%OCAML%%lib/ocaml/llvm_analysis.mli
+%%OCAML%%lib/ocaml/llvm_bitreader.a
+%%OCAML%%lib/ocaml/llvm_bitreader.cma
+%%OCAML%%lib/ocaml/llvm_bitreader.cmi
+%%OCAML%%lib/ocaml/llvm_bitreader.cmx
+%%OCAML%%lib/ocaml/llvm_bitreader.cmxa
+%%OCAML%%lib/ocaml/llvm_bitreader.mli
+%%OCAML%%lib/ocaml/llvm_bitwriter.a
+%%OCAML%%lib/ocaml/llvm_bitwriter.cma
+%%OCAML%%lib/ocaml/llvm_bitwriter.cmi
+%%OCAML%%lib/ocaml/llvm_bitwriter.cmx
+%%OCAML%%lib/ocaml/llvm_bitwriter.cmxa
+%%OCAML%%lib/ocaml/llvm_bitwriter.mli
+%%OCAML%%lib/ocaml/llvm_executionengine.a
+%%OCAML%%lib/ocaml/llvm_executionengine.cma
+%%OCAML%%lib/ocaml/llvm_executionengine.cmi
+%%OCAML%%lib/ocaml/llvm_executionengine.cmx
+%%OCAML%%lib/ocaml/llvm_executionengine.cmxa
+%%OCAML%%lib/ocaml/llvm_executionengine.mli
+%%OCAML%%lib/ocaml/llvm_scalar_opts.a
+%%OCAML%%lib/ocaml/llvm_scalar_opts.cma
+%%OCAML%%lib/ocaml/llvm_scalar_opts.cmi
+%%OCAML%%lib/ocaml/llvm_scalar_opts.cmx
+%%OCAML%%lib/ocaml/llvm_scalar_opts.cmxa
+%%OCAML%%lib/ocaml/llvm_scalar_opts.mli
+%%OCAML%%lib/ocaml/llvm_target.a
+%%OCAML%%lib/ocaml/llvm_target.cma
+%%OCAML%%lib/ocaml/llvm_target.cmi
+%%OCAML%%lib/ocaml/llvm_target.cmx
+%%OCAML%%lib/ocaml/llvm_target.cmxa
+%%OCAML%%lib/ocaml/llvm_target.mli
 %%PORTDOCS%%%%DOCSDIR%%/html.tar.gz
 %%PORTDOCS%%%%DOCSDIR%%/html/AliasAnalysis.html
 %%PORTDOCS%%%%DOCSDIR%%/html/BitCodeFormat.html
@@ -436,6 +501,59 @@
 %%PORTDOCS%%%%DOCSDIR%%/ps/opt.ps
 %%PORTDOCS%%%%DOCSDIR%%/ps/stkrc.ps
 %%PORTDOCS%%%%DOCSDIR%%/ps/tblgen.ps
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc.tar.gz
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.CallConv.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.Fcmp.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.Icmp.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.Linkage.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.MemoryBuffer.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.ModuleProvider.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.PassManager.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.TypeKind.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.Visibility.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_analysis.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_bitreader.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_bitwriter.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_executionengine.ExecutionEngine.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_executionengine.GenericValue.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_executionengine.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_scalar_opts.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_target.Endian.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_target.TargetData.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/Llvm_target.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_attributes.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_class_types.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_classes.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_exceptions.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_methods.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_module_types.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_modules.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_types.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/index_values.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/ocamldoc.tar.gz
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/style.css
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.CallConv.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.Fcmp.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.Icmp.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.Linkage.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.MemoryBuffer.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.ModuleProvider.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.PassManager.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.TypeKind.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.Visibility.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_analysis.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_bitreader.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_bitwriter.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_executionengine.ExecutionEngine.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_executionengine.GenericValue.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_executionengine.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_scalar_opts.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_target.Endian.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_target.TargetData.html
+%%PORTDOCS%%%%OCAML%%%%DOCSDIR%%/ocamldoc/html/type_Llvm_target.html
 @dirrm include/llvm/Transforms/Utils
 @dirrm include/llvm/Transforms/IPO
 @dirrm include/llvm/Transforms
@@ -453,6 +571,8 @@
 @dirrm include/llvm-c/Transforms
 @dirrm include/llvm-c
 @dirrm include/llvm
+%%PORTDOCS%%%%OCAML%%@dirrm %%DOCSDIR%%/ocamldoc/html
+%%PORTDOCS%%%%OCAML%%@dirrm %%DOCSDIR%%/ocamldoc
 %%PORTDOCS%%@dirrm %%DOCSDIR%%/ps
 %%PORTDOCS%%@dirrm %%DOCSDIR%%/html/img
 %%PORTDOCS%%@dirrm %%DOCSDIR%%/html/tutorial
Index: files/patch-lib_Target_X86_X86JITInfo.cpp
===================================================================
RCS file: files/patch-lib_Target_X86_X86JITInfo.cpp
diff -N files/patch-lib_Target_X86_X86JITInfo.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-lib_Target_X86_X86JITInfo.cpp	2 Jul 2008 09:22:26 -0000
@@ -0,0 +1,40 @@
+--- lib/Target/X86/X86JITInfo.cpp.orig	2008-07-02 09:41:02.000000000 +0200
++++ lib/Target/X86/X86JITInfo.cpp	2008-07-02 09:41:51.000000000 +0200
+@@ -25,8 +25,10 @@
+ // Determine the platform we're running on
+ #if defined (__x86_64__) || defined (_M_AMD64)
+ # define X86_64_JIT
++# define ASMSUFFIX "@PLT"
+ #elif defined(__i386__) || defined(i386) || defined(_M_IX86)
+ # define X86_32_JIT
++# define ASMSUFFIX
+ #endif
+ 
+ void X86JITInfo::replaceMachineCodeForFunction(void *Old, void *New) {
+@@ -112,7 +114,7 @@
+     // JIT callee
+     "movq    %rbp, %rdi\n"    // Pass prev frame and return address
+     "movq    8(%rbp), %rsi\n"
+-    "call    " ASMPREFIX "X86CompilationCallback2\n"
++    "call    " ASMPREFIX "X86CompilationCallback2" ASMSUFFIX "\n"
+     // Restore all XMM arg registers
+     "movaps  112(%rsp), %xmm7\n"
+     "movaps  96(%rsp), %xmm6\n"
+@@ -186,7 +188,7 @@
+     "movl    4(%ebp), %eax\n" // Pass prev frame and return address
+     "movl    %eax, 4(%esp)\n"
+     "movl    %ebp, (%esp)\n"
+-    "call    " ASMPREFIX "X86CompilationCallback2\n"
++    "call    " ASMPREFIX "X86CompilationCallback2" ASMSUFFIX "\n"
+     "movl    %ebp, %esp\n"    // Restore ESP
+     CFI(".cfi_def_cfa_register %esp\n")
+     "subl    $12, %esp\n"
+@@ -240,7 +242,7 @@
+     "movl    4(%ebp), %eax\n" // Pass prev frame and return address
+     "movl    %eax, 4(%esp)\n"
+     "movl    %ebp, (%esp)\n"
+-    "call    " ASMPREFIX "X86CompilationCallback2\n"
++    "call    " ASMPREFIX "X86CompilationCallback2" ASMSUFFIX "\n"
+     "addl    $16, %esp\n"
+     "movaps  48(%esp), %xmm3\n"
+     CFI(".cfi_restore %xmm3\n")


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list