public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* Split patch for Mac OS/ was Re: Help with Building toolchain with  crosstool-ng on Mac OS X 10.6.2  (Snow Leopard)
@ 2010-02-02 23:24 tvb377
  2010-02-03 23:17 ` Yann E. MORIN
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: tvb377 @ 2010-02-02 23:24 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: crossgcc

[-- Attachment #1: Type: text/plain, Size: 3403 bytes --]

Hi Yann, all,
> Also, if you would provide mercurial patches, it would be easier to work
> with. See docs/overview.txt, section "Contributing".
Sorry, I'm quite new to mercurial. And I guess the last step in
"Contributing" means it wants to send emails, which I cannot provide 
on this machine here in reasonable time.
Next time I'll use it, promised ;-)

> One patch per new tool, please. Also, be sure to see how it plays with
> the companion tools that were recently added.
OK. Except the expanded list of gnu tools added in configure+Makefile.in,
because all added tools get to use the same mechanism already
employed that makes sure that they actually get called.
--> if it works for sed, it also works for objdump.

> > - make all calls to stat(1) dependent to `uname -s` or replace the call.
> One patch for that.
OK.

> > - replace all calls to readlink(1GNU) with compatible variants.
> "readlink -e" and "readlink" are not equivalent.
No, but
a) ct-ng does not use libs it searches for (here only ncurses) by itself.
b) The variable where is dropped for libs, afaik. It is also
   questionnable if you would actually need the shared object instead of
   the link.
c) I'm not aware of installations where links point to links 
   [that point to links...] that point to shared objects.
   Then the check could in theory fail when removing the -e

> > - uname -o is not portable. use -s when -o fails
> Ditto.
OK

> > - a bug in the sed-expression that sets the nanoseconds to 0 for a
> >   date(1) not handling %N
> So this change seems to imply that on MacOS-X or *BSD, we get:
>   > date +%N
>   N
> Right?
Right.

> And I have the tools for x86_64-linux-gnu-{gcc,ld,...}, but not the ones
> for
> x86_64-unknown-linux-gnu-{gcc,ld,...}. So it is much more reliable to ask
> gcc than to ask config.guess.
> 
> gcc -dumpmachine will tell us the tuple for which it was configured, and
> that means the prefix to use to the actual tools, which is what we need.
Hmm, I see the point. But apparently then there is an inconsistency here
on Darwin, be it in the gcc configuration or the configure (I think it
was of gmp) that failed.
Anyway, my change only is for Darwin + BSD.

> > - the compiler command line options for compiling wrapper.c crashes gcc
> >   on MacOS (and IMHO were a little bit overdone for the complexity of
> >   wrapper.c).
> Separate patch for that.
OK.

> Statically linking should hopefully speed up things. Having a /slow/
> wrapper is not very interesting, is it? Of course, the ratio
> time-in-wrapper / (time-in-wrapper + time-in-actual-tool) should be
> fairly small, except for very trivial programs, where the total time
> will anyway be almost imperceptible...
imho, statically linking will not buy you a measurable amount of time,
especially not when linking only to such mundane things like libc that
are guaranteed to be in core, anyway.

> > - under Darwin, use DYLD_LIBRARY_PATH in wrapper.c
> Separate patch for that as well.
OK. Please note that this patch requires the above cmd line patch.

> > - added printenv to the build.log (I found that helpful).
> Separate patch.
OK.

Hope it fits now for you. Please note that
- all patches (except for build-mpfr and using config.guess)
  are necessary to run crosstool-ng itself.
- all are tested except the one in populate.in

Sorry for the inconvenience that these are not mercurial-sent patches.

Regards
Titus

[-- Attachment #2: build-mpfr-on-darwin.patch --]
[-- Type: application/octet-stream, Size: 485 bytes --]

diff -r 160fc94ed49f scripts/build/companion_libs/mpfr.sh
--- a/scripts/build/companion_libs/mpfr.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/companion_libs/mpfr.sh	Tue Feb 02 23:11:25 2010 +0100
@@ -75,6 +75,7 @@
     case "${CT_HOST}" in
         *cygwin*)   mpfr_opt="--disable-thread-safe";;
         *mingw*)    mpfr_opt="--disable-thread-safe";;
+        *darwin*)   mpfr_opt="--disable-thread-safe";;
         *)          mpfr_opt="--enable-thread-safe";;
     esac
 

[-- Attachment #3: corrected-date-sed-expr.patch --]
[-- Type: application/octet-stream, Size: 355 bytes --]

diff -r 160fc94ed49f scripts/functions
--- a/scripts/functions	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/functions	Tue Feb 02 23:11:25 2010 +0100
@@ -192,7 +192,7 @@
 # to the highest entire second
 # Usage: CT_DoDate <fmt>
 CT_DoDate() {
-    date "$1" |sed -r -e 's/%N$/000000000/;'
+    date "$1" |sed -r -e 's/N$/000000000/;'
 }
 
 CT_STEP_COUNT=1

[-- Attachment #4: dyld-library-path-wrapper.c.patch --]
[-- Type: application/octet-stream, Size: 966 bytes --]

diff -r 160fc94ed49f scripts/wrapper.c
--- a/scripts/wrapper.c	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/wrapper.c	Tue Feb 02 23:11:25 2010 +0100
@@ -7,6 +7,11 @@
 #include <unistd.h>
 #include <errno.h>
 
+#ifdef	Darwin
+static const char * ldlp = "DYLD_LIBRARY_PATH";
+#else
+static const char * ldlp = "LD_LIBRARY_PATH";
+#endif
 
 /* Needed for execve */
 extern char **environ;
@@ -106,7 +111,7 @@
 
   /* Now add the directory with our runtime libraries to the
      front of the library search path, LD_LIBRARY_PATH */
-  ldlibpath = getenv( "LD_LIBRARY_PATH" );
+  ldlibpath = getenv(ldlp);
   if( ldlibpath ) {
     basedir = (char*) realloc( basedir,   strlen( basedir )
                                         + strlen( ldlibpath )
@@ -115,7 +120,7 @@
     strcat( basedir, ldlibpath );
   }
 
-  if( setenv( "LD_LIBRARY_PATH", basedir, 1 ) ) {
+  if( setenv( ldlp, basedir, 1 ) ) {
     errno = ENOMEM;
     perror( "tool wrapper" );
     exit( 1 );

[-- Attachment #5: gnu-tools.patch --]
[-- Type: application/octet-stream, Size: 2474 bytes --]

diff -r 160fc94ed49f Makefile.in
--- a/Makefile.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/Makefile.in	Tue Feb 02 23:11:25 2010 +0100
@@ -52,6 +52,11 @@
 grep   := @@grep@@
 make   := @@make@@
 sed    := @@sed@@
+libtool:= @@libtool@@
+objcopy:= @@objcopy@@
+objdump:= @@objdump@@
+readelf:= @@readelf@@
+patch  := @@patch@@
 
 ###############################################################################
 # Sanity checks
@@ -139,6 +144,11 @@
 	  echo "export grep=$(grep)";       \
 	  echo "export make=$(make)";       \
 	  echo "export sed=$(sed)";         \
+	  echo "export libtool=$(libtool)"; \
+	  echo "export objcopy=$(objcopy)"; \
+	  echo "export objdump=$(objdump)"; \
+	  echo "export readelf=$(readelf)"; \
+	  echo "export patch=$(patch)";     \
 	 ) >paths.mk
 
 #--------------------------------------
diff -r 160fc94ed49f configure
--- a/configure	Sun Jan 31 23:04:35 2010 +0100
+++ b/configure	Tue Feb 02 23:11:25 2010 +0100
@@ -346,17 +346,17 @@
              ver='^GNU Make (3.[89][[:digit:]]|[4-9])'  \
              err="GNU 'make' 3.80 or above was not found"
 has_or_abort prog=gcc
-has_or_abort prog="awk gawk" ver='^GNU Awk' err="GNU 'awk' was not found"
+has_or_abort prog="gawk awk" ver='^GNU Awk' err="GNU 'awk' was not found"
 has_or_abort prog=bison
 has_or_abort prog=flex
 has_or_abort prog=makeinfo
 has_or_abort prog=automake                                                      \
              ver='\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)'    \
              err="'automake' 1.10 or above was not found"
-has_or_abort prog=libtool                                                                           \
+has_or_abort prog=libtool var=libtool                                                               \
              ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)'   \
              err="'libtool' 1.5.26 or above was not found"
-has_or_abort prog=stat ver='GNU coreutils'
+has_or_abort prog=stat
 has_or_abort prog="aria2c curl wget"
 has_or_abort prog=cvs
 has_or_abort prog=patch
@@ -365,6 +365,10 @@
 has_or_abort prog=bzip2
 has_or_abort prog=lzma
 has_or_abort prog=readlink
+has_or_abort prog=objcopy var=objcopy
+has_or_abort prog=objdump var=objdump
+has_or_abort prog=readelf var=readelf
+has_or_abort prog=patch var=patch
 
 has_or_abort inc="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"    \
              err="'ncurses' headers files were not found"

[-- Attachment #6: nice-to-see-all-envvars.patch --]
[-- Type: application/octet-stream, Size: 464 bytes --]

diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Tue Feb 02 23:11:25 2010 +0100
@@ -483,6 +488,8 @@
     CT_DoLog EXTRA "  host   = ${CT_REAL_HOST}"
     CT_DoLog EXTRA "  target = ${CT_TARGET}"
     set |grep -E '^CT_.+=' |sort |CT_DoLog DEBUG
+    CT_DoLog DEBUG "  Other environment:"
+    printenv |grep -v -E '^CT_.+=' |sort |CT_DoLog DEBUG
     CT_EndStep
 fi
 

[-- Attachment #7: readlink.patch --]
[-- Type: application/octet-stream, Size: 1639 bytes --]

diff -r 160fc94ed49f configure
--- a/configure	Sun Jan 31 23:04:35 2010 +0100
+++ b/configure	Tue Feb 02 23:11:25 2010 +0100
@@ -160,7 +160,7 @@
                 printf "Checking for '${item}'... "
                 where="$( gcc -print-file-name="${item}" )"
                 if [ "${where}" != "${item}" ]; then
-                    where="$( readlink -e "${where}" )"
+                    where="$( readlink "${where}" )"
                     status=yes
                     break;
                 fi
diff -r 160fc94ed49f scripts/wrapper.in
--- a/scripts/wrapper.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/wrapper.in	Tue Feb 02 23:11:25 2010 +0100
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+# this wrapper will not work under BSD systems or others
+# not containig the GNU readlink.
+# Under those, wrapper.c will forcibly be used
+# regardless of the config file setting.
+
 canonicalizedname=$(readlink -nm "${0}")
 dirname="$(dirname "${canonicalizedname}")"
 basename="$(basename "${canonicalizedname}")"
diff -r 160fc94ed49f scripts/build/internals.sh
--- a/scripts/build/internals.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/internals.sh	Tue Feb 02 23:11:25 2010 +0100
@@ -42,6 +42,11 @@
         CT_DoLog EXTRA "Installing toolchain wrappers"
         CT_Pushd "${CT_PREFIX_DIR}/bin"
 
+        if [ "$CT_SYS_OS" = "Darwin" -o "$CT_SYS_OS" = "FreeBSD" ] ; then
+            # wrapper does not work (when using readlink -m)
+            CT_DoLog EXTRA "Forcing usage of binary wrappers"
+            CT_TOOLS_WRAPPER="exec"
+        fi
         # Install the wrapper
         case "${CT_TOOLS_WRAPPER}" in
             script)

[-- Attachment #8: samples.mk-sed.patch --]
[-- Type: application/octet-stream, Size: 1147 bytes --]

diff -r 160fc94ed49f samples/samples.mk
--- a/samples/samples.mk	Sun Jan 31 23:04:35 2010 +0100
+++ b/samples/samples.mk	Tue Feb 02 23:11:25 2010 +0100
@@ -5,10 +5,10 @@
 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
 CT_SAMPLES := $(shell echo $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES))  \
-                      |sed -r -e 's/ /\n/g;'                            \
-                      |sed -r -e 's/(.*),(.*)/\2,\1/;'                  \
+                      |$(sed) -r -e 's/ /\n/g;'                            \
+                      |$(sed) -r -e 's/(.*),(.*)/\2,\1/;'                  \
                       |LC_ALL=C sort                                    \
-                      |sed -r -e 's/(.*),(.*)/\2,\1/;'                  \
+                      |$(sed) -r -e 's/(.*),(.*)/\2,\1/;'                  \
                )
 
 # ----------------------------------------------------------

[-- Attachment #9: sed-portable.patch --]
[-- Type: application/octet-stream, Size: 829 bytes --]

diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Tue Feb 02 23:11:25 2010 +0100
@@ -474,7 +479,7 @@
     CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
     CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
     CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
-    CT_DoExecLog DEBUG sed -r -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
+    CT_DoExecLog DEBUG sed -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
     bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
 
     CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"

[-- Attachment #10: uname-portable.patch --]
[-- Type: application/octet-stream, Size: 591 bytes --]

diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Tue Feb 02 23:11:25 2010 +0100
@@ -189,8 +189,8 @@
 CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
 CT_SYS_KERNEL=$(uname -s)
 CT_SYS_REVISION=$(uname -r)
-# MacOS X lacks '-o' :
-CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
+# uname -o is a GNU Extension. Others lack '-o' --> use System name for OS name.
+CT_SYS_OS=$(uname -o || uname -s)
 CT_SYS_MACHINE=$(uname -m)
 CT_SYS_PROCESSOR=$(uname -p)
 CT_SYS_GCC=$(gcc -dumpversion)

[-- Attachment #11: use-configguess-on-bsd.patch --]
[-- Type: application/octet-stream, Size: 802 bytes --]

diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Tue Feb 02 23:11:25 2010 +0100
@@ -326,7 +326,12 @@
     # Determine build system if not set by the user
     CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
     case "${CT_BUILD}" in
-        "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
+        "") if [ "$CT_SYS_OS" = "Darwin" -o "$CT_SYS_OS" = "FreeBSD" ] ; then
+                CT_BUILD=$(CT_DoConfigGuess)
+            else
+                CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine)
+            fi
+            ;;
     esac
 
     # Prepare mangling patterns to later modify BUILD and HOST (see below)

[-- Attachment #12: whyclearCT_CFLAGS_FOR_HOST.patch --]
[-- Type: application/octet-stream, Size: 520 bytes --]

diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Tue Feb 02 23:11:25 2010 +0100
@@ -454,7 +459,7 @@
     CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/buildtools/makeinfo"
 
     # Help gcc
-    CT_CFLAGS_FOR_HOST=
+    # Why clear that ? CT_CFLAGS_FOR_HOST=
     [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
 
     # Override the configured jobs with what's been given on the command line

[-- Attachment #13: wrapper-compile-commandline.patch --]
[-- Type: application/octet-stream, Size: 896 bytes --]

diff -r 160fc94ed49f scripts/build/internals.sh
--- a/scripts/build/internals.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/internals.sh	Tue Feb 02 23:11:25 2010 +0100
@@ -55,9 +60,8 @@
                 if [ "${CT_DEBUG_CT}" = "y" ]; then
                   _t="" # If debugging crosstool-NG, don't strip the wrapper
                 fi
-                CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
-                                   -Wall -Wextra -Wunreachable-code -Werror   \
-                                   -O3 -static ${_t}                          \
+                CT_DoExecLog DEBUG "cc" -Wall -Wextra -Werror        \
+                                   -O -D$CT_SYS_OS ${_t}             \
                                    "${CT_LIB_DIR}/scripts/wrapper.c"          \
                                    -o ".${CT_TARGET}-wrapper"
                 ;;

[-- Attachment #14: stat-portable.patch --]
[-- Type: application/octet-stream, Size: 2417 bytes --]

diff -r 160fc94ed49f scripts/build/internals.sh
--- a/scripts/build/internals.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/internals.sh	Tue Feb 02 23:11:25 2010 +0100
@@ -68,7 +72,7 @@
         # scripts, we don't know if they would in the end spawn a binary...
         # Just skip symlinks
         for _t in "${CT_TARGET}-"*; do
-            if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then
+            if [ -z "`readlink ${_t}`" ]; then
                 CT_DoExecLog ALL mv "${_t}" ".${_t}"
                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
             fi
diff -r 160fc94ed49f scripts/functions
--- a/scripts/functions	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/functions	Tue Feb 02 23:11:25 2010 +0100
@@ -249,7 +249,17 @@
     local mode
     for dir in "${@}"; do
         [ -d "${dir}" ] || continue
-        mode="$(stat -c '%a' "$(dirname "${dir}")")"
+        case "$CT_SYS_OS" in
+            GNU/Linux)
+                mode="$(stat -c '%a' "$(dirname "${dir}")")"
+                ;;
+            Darwin|FreeBSD)
+                mode="$(stat -f '%Lp' "$(dirname "${dir}")")"
+                ;;
+            *)
+                CT_Abort "Unhandled host OS $CT_SYS_OS"
+                ;;
+        esac
         CT_DoExecLog ALL chmod u+w "$(dirname "${dir}")"
         CT_DoExecLog ALL chmod -R u+w "${dir}"
         CT_DoExecLog ALL rm -rf "${dir}"
diff -r 160fc94ed49f scripts/populate.in
--- a/scripts/populate.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/populate.in	Tue Feb 02 23:11:25 2010 +0100
@@ -64,6 +64,22 @@
 _EOF_
 }
 
+# return the inode of a file in a portable way
+CT_getinode() {
+    case `uname -s` in
+        *BSD|Darwin)
+            stat -f '%i' $1
+            ;;
+        Linux)
+            stat -c '%i' $1
+            ;;
+        *)
+            echo "OS unknown";
+            exit 1
+            ;;
+    esac
+}
+
 CT_ROOT_SRC_DIR=
 CT_ROOT_DST_DIR=
 CT_LIB_LIST=
@@ -104,8 +120,8 @@
     echo "$myname: '${CT_ROOT_DST_DIR}': already exists"
     exit 1
 fi
-src_inode=$(stat -c '%i' "${CT_ROOT_SRC_DIR}/.")
-dst_inode=$(stat -c '%i' "${CT_ROOT_DST_DIR}/." 2>/dev/null || true)
+src_inode=$(CT_getinode "${CT_ROOT_SRC_DIR}/.")
+dst_inode=$(CT_getinode "${CT_ROOT_DST_DIR}/." 2>/dev/null || true)
 if [ "${src_inode}" -eq "$((dst_inode+0))" ]; then
     echo "$myname: source and destination are the same!"
     exit 1

[-- Attachment #15: Type: text/plain, Size: 71 bytes --]

--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-02-20 22:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-02 23:24 Split patch for Mac OS/ was Re: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2 (Snow Leopard) tvb377
2010-02-03 23:17 ` Yann E. MORIN
2010-02-18 19:54 ` Yann E. MORIN
2010-02-18 20:33 ` Yann E. MORIN
2010-02-19  6:15   ` Titus von Boxberg
2010-02-20 20:33     ` Yann E. MORIN
2010-02-20 22:34       ` Titus von Boxberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).