[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Perl bindings for libtcc available on Linux and Windo

From: David Mertens
Subject: Re: [Tinycc-devel] Perl bindings for libtcc available on Linux and Windows. Mac help?
Date: Sat, 17 Aug 2013 23:47:22 -0400

Hello everyone -

The Perl bindings have worked so far for Windows using MinGW and for Linux. I also managed to get libtcc to build under Mac! Actually, it seems that it always built fine under Mac, but it didn't have all of the symbols. My version of OS X is Lion and is 64 bit, as is evident by the __x86_64__ preprocessor symbol being defined. However, uname reports i386, which is a known behavior on Mac. (That was for 10.6, but clearly my system is still exhibiting the same behavior.) Because the preprocessor symbol is defined, but disagrees with uname, tcc's build process assumes that I am trying to cross-compile tcc, and refuses to compile tccrun.c, which is necessary to get tcc_relocate. To solution is easy: pass the  "--cpu=x86-64" option to "./configure". The resulting libtcc.a file then has all (two) of tccrun.c's symbols, and we can link!

However, I wonder if there might be an automatic way for the configure process to determine this. I am not very good at writing configure files (I'm a Perl guy, not a Shell guy). Attached below is a patch that might be acceptable for figuring this out in a Darwin-specific way. I didn't commit the patch to the mob branch because I'm sure it's a hack, and I'd appreciate if somebody who knows what they're doing could look it over and tell me what I'm doing wrong.


diff --git a/configure b/configure
index b513cc1..bfceed0 100755
--- a/configure
+++ b/configure
@@ -56,6 +56,27 @@ case $targetos in
   DragonFly) noldl=yes;;
   OpenBSD)   noldl=yes;;
   FreeBSD)   noldl=yes;;
+  Darwin)
+      # Have to try harder to get CPU architecture
+      cat >arch-test.c <<EOF
+        #include <stdio.h>
+        int main() {
+          #ifdef __x86_64__
+            /* this is x86_64, not x86-64, given the logic the cpu var below */
+            printf("x86_64");
+          #elif defined __i386__
+            printf("i386");
+          #else
+            printf("unknown");
+          #endif
+        }
+      $cc arch-test.c -o arch-test
+      cpu=`./arch-test`
+      echo "arch-test gave $cpu"
+      rm arch-test
+      rm arch-test.c
+      ;;
   *) ;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]