From e89960a53f6e10550f86588be705b3c6eb09d159 Mon Sep 17 00:00:00 2001
From: matoro <matoro@users.noreply.github.com>
Date: Mon, 22 Jul 2024 17:40:20 -0400
Subject: [PATCH 1/2] Use -fPIC on Linux instead of -fpic

On most platforms, these are identical.  However, on a small list of
platforms, the small -fpic will enforce a limit on GOT size.  However,
if -fPIC is used instead, then the GOT on these platforms will have no
limits.  The affected platforms and the respective GOT limits with -fpic
are:  8k on sparc, 28k on aarch64, and 32k on m68k and powerpc.

See: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fpic
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 25cdee1457..8561d27b35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,7 +230,7 @@ then
 		 fi;;
 	s390x*-*-*) CCSHARED="-fpic" ;;
 	s390*-*-*) CCSHARED="-fPIC" ;;
-	*-*-linux*) CCSHARED="-fpic";;
+	*-*-linux*) CCSHARED="-fPIC";;
 	*-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";;
 	*-*-netbsd*) CCSHARED="-fPIC";;
 	*-sco-sysv*) CCSHARED="-KPIC -dy -Bdynamic";;

From 16129d98041586af75f4c4cb71758e0eb3b49e6a Mon Sep 17 00:00:00 2001
From: matoro <matoro@users.noreply.github.com>
Date: Mon, 22 Jul 2024 17:46:29 -0400
Subject: [PATCH 2/2] Update examples to recommend compiling with -fPIC instead
 of -fpic

To reflect previous change to swig defaults.
---
 Examples/go/simple/index.html | 6 +++---
 Examples/perl5/index.html     | 2 +-
 Examples/python/index.html    | 2 +-
 Examples/ruby/index.html      | 2 +-
 Examples/tcl/index.html       | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Examples/go/simple/index.html b/Examples/go/simple/index.html
index 21dfc239ed..45ec980cda 100644
--- a/Examples/go/simple/index.html
+++ b/Examples/go/simple/index.html
@@ -72,10 +72,10 @@ <h2>Compilation</h2>
   named <tt>example.a</tt>; e.g., <tt>gopack grc example.a example.6
   example_gc.6</tt>.
 <li>Compile the <tt><a href="example_wrap.c">example_wrap.c</a></tt>
-  file using your standard C compiler with the <tt>-fpic</tt> option;
-  e.g., <tt>gcc -c -O -fpic example_wrap.c</tt>.
+  file using your standard C compiler with the <tt>-fPIC</tt> option;
+  e.g., <tt>gcc -c -O -fPIC example_wrap.c</tt>.
 <li>Also compile the actual code, not generated by SWIG; e.g., <tt>gcc
-    -c -O -fpic example.c</tt>.
+    -c -O -fPIC example.c</tt>.
 <li>Put the gcc compiled object files into a shared library;
   e.g., <tt>gcc -shared -o example.so example_wrap.o example.o</tt>.
 <li>Compile the program which demonstrates how to use the library;
diff --git a/Examples/perl5/index.html b/Examples/perl5/index.html
index 2daabaaf9c..122923bdc9 100644
--- a/Examples/perl5/index.html
+++ b/Examples/perl5/index.html
@@ -42,7 +42,7 @@ <h2>Compilation Issues</h2>
 <blockquote>
 <pre>
 % swig -perl5 interface.i
-% gcc -fpic -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
+% gcc -fPIC -c -Dbool=char -I/usr/lib/perl5/5.00503/i386-linux/CORE interface_wrap.c
 % gcc -shared interface_wrap.o $(OBJS) -o interface.so 
 % perl
 use interface;
diff --git a/Examples/python/index.html b/Examples/python/index.html
index fcb7eace8b..97c2036330 100644
--- a/Examples/python/index.html
+++ b/Examples/python/index.html
@@ -44,7 +44,7 @@ <h2>Compilation Issues</h2>
 <blockquote>
 <pre>
 % swig -python interface.i
-% gcc -fpic -c interface_wrap.c -I/usr/local/include/python1.5
+% gcc -fPIC -c interface_wrap.c -I/usr/local/include/python1.5
 % gcc -shared interface_wrap.o $(OBJS) -o interfacemodule.so 
 % python
 Python 1.5.2 (#3, Oct  9 1999, 22:09:34)  [GCC 2.95.1 19990816 (release)] on linux2
diff --git a/Examples/ruby/index.html b/Examples/ruby/index.html
index ceb6c925d4..dee00c1d14 100644
--- a/Examples/ruby/index.html
+++ b/Examples/ruby/index.html
@@ -45,7 +45,7 @@ <h2>Compilation Issues</h2>
 <blockquote>
 <pre>
 % swig -ruby interface.i
-% gcc -fpic -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
+% gcc -fPIC -c interface_wrap.c -I/usr/local/lib/ruby/1.4/i686-linux
 % gcc -shared interface_wrap.o $(OBJS) -o interface.so 
 % ruby
 require 'interface'
diff --git a/Examples/tcl/index.html b/Examples/tcl/index.html
index acd90029f3..5048186c67 100644
--- a/Examples/tcl/index.html
+++ b/Examples/tcl/index.html
@@ -44,7 +44,7 @@ <h2>Compilation Issues</h2>
 <blockquote>
 <pre>
 unix % swig -tcl interface.i
-unix % gcc -fpic -c interface_wrap.c -I/usr/local/include
+unix % gcc -fPIC -c interface_wrap.c -I/usr/local/include
 unix % gcc -shared interface_wrap.o $(OBJS) -o interface.so
 unix % tclsh8.3
 % load ./interface.so
