[packages/ocaml] - added opt bcond to skip building native compiler (only bytecode) - added x32 support from http://c

baggins baggins at pld-linux.org
Sat Jan 3 20:22:41 CET 2015


commit dc9de8a526e2cbae594e17bbd8241fc9e723ba06
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Jan 3 19:20:51 2015 +0000

    - added opt bcond to skip building native compiler (only bytecode)
    - added x32 support from http://caml.inria.fr/mantis/view.php?id=6722
    - use target_platform forselecting build host

 ocaml.spec |  31 +++++++++++++------
 x32.patch  | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 124 insertions(+), 10 deletions(-)
---
diff --git a/ocaml.spec b/ocaml.spec
index 12e2fb2..5289fc8 100644
--- a/ocaml.spec
+++ b/ocaml.spec
@@ -2,6 +2,11 @@
 # Conditional build:
 %bcond_without	emacs	# without emacs subpackage
 %bcond_without	x	# without X11 support 
+%bcond_without	opt	# don't build native, optimized compiler
+
+%ifarch x32
+%undefine	with_opt
+%endif
 
 %define		sver	4.02
 
@@ -28,6 +33,7 @@ Source5:	http://www.ocaml.info/ocaml_sources/ds-contrib.tar.gz
 # Source5-md5:	77fa1da7375dea1393cc0b6cd802d7e1
 Patch1:		%{name}-CFLAGS.patch
 Patch2:		%{name}-as_needed.patch
+Patch3:		x32.patch
 URL:		http://caml.inria.fr/
 %{?with_x:BuildRequires:	xorg-lib-libX11-devel}
 %if %{with emacs}
@@ -225,20 +231,24 @@ mv htmlman docs/html/ocaml
 cp %{SOURCE2} docs/ocaml.ps.gz
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %build 
 cp -f /usr/share/automake/config.sub config/gnu
 ./configure \
+	-host %{_target_platform} \
         -cc "%{__cc}" \
 	-bindir %{_bindir} \
 	-libdir %{_libdir}/%{name} \
 	-mandir %{_mandir}/man1 \
-	-host %{_host} \
 	-with-pthread \
 	-x11lib %{_libdir}
 
-%{__make} -j1 world bootstrap opt.opt CFLAGS="%{rpmcflags} -Wall -DUSE_INTERP_RESULT"
-%{__make} -C tools objinfo CFLAGS="%{rpmcflags} -Wall -DUSE_INTERP_RESULT" -j1
+%{__make} -j1 world bootstrap %{?with_opt:opt.opt} \
+	CFLAGS="%{rpmcflags} -Wall -DUSE_INTERP_RESULT"
+
+%{__make} -C tools objinfo \
+	CFLAGS="%{rpmcflags} -Wall -DUSE_INTERP_RESULT" -j1
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -279,7 +289,8 @@ ln -s ../../include/caml $RPM_BUILD_ROOT%{_libdir}/%{name}/caml
 # compiled sources of compiler, needed by some programs
 for f in {asm,byte}comp parsing typing utils ; do
 	install -d $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f
-	cp $f/*.{cmi,cmo,cmx,o} $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f
+	cp $f/*.{cmi,cmo} $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f
+	%{?with_opt:cp $f/*.{cmx,o} $RPM_BUILD_ROOT%{_libdir}/%{name}/compiler/$f}
 done
 
 # this isn't installed by default, but is useful
@@ -309,7 +320,7 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/ocaml
 %attr(755,root,root) %{_bindir}/ocamlbuild*
 %attr(755,root,root) %{_bindir}/ocamlc
-%attr(755,root,root) %{_bindir}/ocamlc.*
+%{?with_opt:%attr(755,root,root) %{_bindir}/ocamlc.*}
 %attr(755,root,root) %{_bindir}/ocamlcp
 %attr(755,root,root) %{_bindir}/ocamldebug
 %attr(755,root,root) %{_bindir}/ocamldep*
@@ -318,8 +329,8 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/ocamlmklib
 %attr(755,root,root) %{_bindir}/ocamlmktop
 %attr(755,root,root) %{_bindir}/ocamlobjinfo
-%attr(755,root,root) %{_bindir}/ocamlopt
-%attr(755,root,root) %{_bindir}/ocamlopt.*
+%{?with_opt:%attr(755,root,root) %{_bindir}/ocamlopt}
+%{?with_opt:%attr(755,root,root) %{_bindir}/ocamlopt.*}
 %attr(755,root,root) %{_bindir}/ocamloptp
 %attr(755,root,root) %{_bindir}/ocamlprof
 %attr(755,root,root) %{_bindir}/ocamlyacc
@@ -332,7 +343,7 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_libdir}/%{name}/vmthreads/*.cm*
 %dir %{_libdir}/%{name}/vmthreads/*.a
 %{_libdir}/%{name}/*.a
-%{_libdir}/%{name}/*.o
+%{?with_opt:%{_libdir}/%{name}/*.o}
 %{_libdir}/%{name}/*.cm*
 %exclude %{_libdir}/%{name}/*graphics*
 %{_libdir}/%{name}/Makefile.config
@@ -395,7 +406,7 @@ rm -rf $RPM_BUILD_ROOT
 %files x11graphics-devel
 %defattr(644,root,root,755)
 %{_libdir}/%{name}/graphics*.cm*
-%{_libdir}/%{name}/graphics.a
+%{?with_opt:%{_libdir}/%{name}/graphics.a}
 %{_libdir}/%{name}/libgraphics.a
 %endif
 
@@ -406,7 +417,7 @@ rm -rf $RPM_BUILD_ROOT
 %files ocamldoc-devel
 %defattr(644,root,root,755)
 %{_libdir}/%{name}/ocamldoc/*.cm*
-%{_libdir}/%{name}/ocamldoc/*.a
+%{?with_opt:%{_libdir}/%{name}/ocamldoc/*.a}
 
 %files examples
 %defattr(644,root,root,755)
diff --git a/x32.patch b/x32.patch
new file mode 100644
index 0000000..38242a5
--- /dev/null
+++ b/x32.patch
@@ -0,0 +1,103 @@
+Package: src:ocaml
+Version: 4.02.1-2
+Severity: wishlist
+Tags: patch
+User: debian-x32 at lists.debian.org
+Usertags: port-x32
+
+
+Please apply the attached patch, it adds support for x32 (as non-native).
+It's made against 4.02.1-2 (in experimental) as I guess you're not going
+to ever upload 4.01 again other than for eventual RC bug fixes.
+
+As you can see, the main problem is the current code confusing x32 for
+sometimes amd64 sometimes i386.  I guess adding native optimized support
+wouldn't be hard (copying parts of i386 and parts of amd64...), but, not
+knowing anything about ocaml or the compiler, I preferred to keep it safe.
+</pre><pre>--- ocaml-4.02.1.orig/byterun/signals_machdep.h
++++ ocaml-4.02.1/byterun/signals_machdep.h
+@@ -25,10 +25,19 @@
+ 
+ #elif defined(__GNUC__) && defined(__x86_64__)
+ 
++#ifdef __ILP32__
++/* x32 */
++#define Read_and_clear(dst,src) \
++  asm("xorl %0, %0; xchgl %0, %1" \
++      : "=r" (dst), "=m" (src) \
++      : "m" (src))
++#else
++/* amd64 */
+ #define Read_and_clear(dst,src) \
+   asm("xorq %0, %0; xchgq %0, %1" \
+       : "=r" (dst), "=m" (src) \
+       : "m" (src))
++#endif
+ 
+ #elif defined(__GNUC__) && defined(__ppc__)
+ 
+--- ocaml-4.02.1.orig/configure
++++ ocaml-4.02.1/configure
+@@ -832,6 +832,7 @@ case "$target" in
+   arm*-*-linux-gnueabi)         arch=arm; system=linux_eabi;;
+   arm*-*-openbsd*)              arch=arm; system=bsd;;
+   zaurus*-*-openbsd*)           arch=arm; system=bsd;;
++  x86_64-*-linux-gnux32)        arch=x32; system=linux;;
+   x86_64-*-linux*)              arch=amd64; system=linux;;
+   x86_64-*-gnu*)                arch=amd64; system=gnu;;
+   x86_64-*-freebsd*)            arch=amd64; system=freebsd;;
+--- ocaml-4.02.1.orig/otherlibs/num/bng.c
++++ ocaml-4.02.1/otherlibs/num/bng.c
+@@ -17,7 +17,7 @@
+ #include "config.h"
+ 
+ #if defined(__GNUC__) && BNG_ASM_LEVEL > 0
+-#if defined(BNG_ARCH_ia32)
++#if defined(BNG_ARCH_ia32) || defined(BNG_ARCH_x32)
+ #include "bng_ia32.c"
+ #elif defined(BNG_ARCH_amd64)
+ #include "bng_amd64.c"
+--- ocaml-4.02.1.orig/otherlibs/num/bng_ia32.c
++++ ocaml-4.02.1/otherlibs/num/bng_ia32.c
+@@ -187,7 +187,7 @@ static bngdigit bng_ia32_mult_sub_digit
+    This is faster than the plain IA32 code above on the Pentium 4.
+    (Arithmetic operations with carry are slow on the Pentium 4). */
+ 
+-#if BNG_ASM_LEVEL >= 2
++#if BNG_ASM_LEVEL >= 2 || defined(__x86_64__)
+ 
+ static bngcarry bng_ia32sse2_add
+        (bng a/*[alen]*/, bngsize alen,
+@@ -393,6 +393,13 @@ static int bng_ia32_sse2_supported(void)
+ 
+ static void bng_ia32_setup_ops(void)
+ {
++#ifdef __x86_64__
++  /* x32 -- SSE2 always supported */
++  bng_ops.add = bng_ia32sse2_add;
++  bng_ops.sub = bng_ia32sse2_sub;
++  bng_ops.mult_add_digit = bng_ia32sse2_mult_add_digit;
++  bng_ops.mult_sub_digit = bng_ia32sse2_mult_sub_digit;
++#else
+ #if BNG_ASM_LEVEL >= 2
+   if (bng_ia32_sse2_supported()) {
+     bng_ops.add = bng_ia32sse2_add;
+@@ -406,6 +413,7 @@ static void bng_ia32_setup_ops(void)
+   bng_ops.sub = bng_ia32_sub;
+   bng_ops.mult_add_digit = bng_ia32_mult_add_digit;
+   bng_ops.mult_sub_digit = bng_ia32_mult_sub_digit;
++#endif
+ }
+ 
+ #define BNG_SETUP_OPS bng_ia32_setup_ops()
+--- ocaml-4.02.1.orig/testsuite/makefiles/Makefile.common
++++ ocaml-4.02.1/testsuite/makefiles/Makefile.common
+@@ -68,7 +68,7 @@ OCAMLMKLIB=$(OCAMLRUN) $(OTOPDIR)/tools/
+ OCAMLYACC=$(TOPDIR)/yacc/ocamlyacc$(EXE)
+ OCAMLBUILD=$(TOPDIR)/_build/ocamlbuild/ocamlbuild.native
+ DUMPOBJ=$(OCAMLRUN) $(OTOPDIR)/tool/dumpobj
+-BYTECODE_ONLY=[ "$(ARCH)" = "none" -o "$(ASM)" = "none" ]
++BYTECODE_ONLY=[ "$(ARCH)" = "none" -o "$(ARCH)" = "x32" -o "$(ASM)" = "none" ]
+ 
+ #FORTRAN_COMPILER=
+ #FORTRAN_LIBRARY=
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/ocaml.git/commitdiff/dc9de8a526e2cbae594e17bbd8241fc9e723ba06



More information about the pld-cvs-commit mailing list