chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] fix Mac OS X build


From: Jim Ursetto
Subject: Re: [Chicken-hackers] [PATCH] fix Mac OS X build
Date: Tue, 28 Jan 2014 12:02:42 -0600

Hi Felix,

For the max-install-name fix, I think you are right, we can abandon support for 
very old XCode.

For the path -- actually, the build tools should be in /usr/bin, and if they 
are not, you just have to run `xcode-select --switch /Applications/XCode.app`.  
This should install the shims into /usr/bin -- at least that's my 
understanding.  You can also use `xcrun` to run command-line tools associated 
with the currently selected XCode, but generally, they should be available 
already as shims in /usr/bin.  If this is correct, I would rather use Apple's 
official method of switching between command-line tools than hardcode it into 
Chicken's makefiles.

Jim

On Jan 28, 2014, at 5:31 AM, Felix Winkelmann <address@hidden> wrote:

> Hello!
> 
> 
> The attached patches try to fix a few problems with building CHICKEN
> on Mac OS X.
> 
> First, the build-tools are not automatically in the PATH, and are
> located somewhere deep in the Xcode.cpp application directory. I've
> added some variables that point to the default locations and which the
> user can override when invoking make(1).
> 
> Second, I added a variable to chicken-config.h that gives the full
> path to the "postinstall" program, which is used on some platforms to
> fix up the runtime linker path for locating libchicken. On Mac this is
> "install_name_tool". "csc" needs to call this on freshly linked
> executables, so it needs to be in chicken-config.h.
> 
> And third, the stupid "max-install-name" thing, which causes the
> invocation of the postinstall program to fail sometimes, depending on
> the installation path length. "csc" needs to do some special magic
> here to and pass "-headerpad_max_install_names" to gcc(1) when
> linking. Jim noted that this might not be supported on older Macs, but
> I vote for using this anyway. It is supported by at least 2
> generations of Xcode, AFAIK, and is the official option provided by
> gcc itself on Darwin. We should support the current generation of the
> official toolchain, I'd say, and in the end the options can be adapted
> manually, in case someone desperately needs to get things running on
> an ancient Mac.
> 
> 
> felix
> From ac788e1fb3ae60c3d0cadfe3864a4251b98c6ef7 Mon Sep 17 00:00:00 2001
> From: felix <address@hidden>
> Date: Tue, 28 Jan 2014 10:16:09 +0100
> Subject: [PATCH 1/2] Use additional variables in MacOSX makefile to specify
> location of C compiler and build tools. Setting
> -isysroot doesn't seem to be necessary in this case,
> the default being to compile for Mac OS, apparently.
> 
> ---
> Makefile.macosx |  6 +++++-
> README          | 11 ++++++++++-
> 2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile.macosx b/Makefile.macosx
> index 39f395a..fea3ef9 100644
> --- a/Makefile.macosx
> +++ b/Makefile.macosx
> @@ -33,11 +33,14 @@ SRCDIR = ./
> 
> # platform configuration
> 
> +XCODE_DEVELOPER ?= /Applications/Xcode.app/Contents/Developer
> +XCODE_TOOL_PATH ?= 
> $(XCODE_DEVELOPER)/Toolchains/XcodeDefault.xctoolchain/usr/bin
> +C_COMPILER ?= $(XCODE_DEVELOPER)/usr/bin/gcc
> ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
> 
> # commands
> 
> -POSTINSTALL_PROGRAM = install_name_tool
> +POSTINSTALL_PROGRAM = $(XCODE_TOOL_PATH)/install_name_tool
> 
> # options
> 
> @@ -51,6 +54,7 @@ else
> C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer
> endif
> endif
> +LIBRARIAN ?= $(XCODE_TOOL_PATH)/ar
> LINKER_LINK_SHARED_LIBRARY_OPTIONS = -dynamiclib -compatibility_version 1 
> -current_version 1.0 -install_name $@
> POSTINSTALL_PROGRAM_FLAGS = -change 
> lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) 
> $(LIBDIR)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
> LIBRARIAN_OPTIONS = scru
> diff --git a/README b/README
> index bb3a106..059718a 100644
> --- a/README
> +++ b/README
> @@ -442,7 +442,16 @@
> 
>       Mac OS X:
> 
> -       - On 10.6 and 10.7, Chicken may incorrectly select a 32-bit build
> +          - The build currently assumes the Xcode application path is
> +            "/Applications/Xcode.app/", with the C compiler and build
> +            tools being located in the "Contents/Developer/usr/bin"
> +            and
> +            "Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
> +            subdirectories, respectively. To override these locations,
> +            set XCODE_DEVELOPER and XCODE_TOOL_PATH on the make(3)
> +            command line.
> +
> +       - On 10.6 and 10.7, CHICKEN may incorrectly select a 32-bit build
>           environment when it should be building 64-bit, resulting in a
>           build error.  This occurs when you have a 32-bit kernel and a
>           64-bit gcc (that is, on Core 2 Duo systems running 10.6 Desktop).
> -- 
> 1.7.12.4 (Apple Git-37)
> 
> From 1fb9dadeb5f0fdf0994de25c3dfc63244e2c50e7 Mon Sep 17 00:00:00 2001
> From: felix <address@hidden>
> Date: Tue, 28 Jan 2014 10:17:18 +0100
> Subject: [PATCH 2/2] Store name of the post-install program in
> chicken-config, so that csc can pick up the path to
> "install_program_name" on Mac OS. Also pass
> "-headerpad_max_install_names" to the linker when
> building dynamically loadable .so's.
> 
> ---
> Makefile.cygwin | 3 +++
> Makefile.mingw  | 3 +++
> csc.scm         | 5 +++--
> defaults.make   | 3 +++
> 4 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile.cygwin b/Makefile.cygwin
> index 8594882..6989ab8 100644
> --- a/Makefile.cygwin
> +++ b/Makefile.cygwin
> @@ -136,6 +136,9 @@ chicken-defaults.h:
>       echo "#ifndef C_INSTALL_CXX" >>$@
>       echo "# define C_INSTALL_CXX \"$(CXX_COMPILER)\"" >>$@
>       echo "#endif" >>$@
> +     echo "#ifndef C_INSTALL_POSTINSTALL_PROGRAM" >>$@
> +     echo "# define C_INSTALL_POSTINSTALL_PROGRAM 
> \"$(POSTINSTALL_PROGRAM)\"" >>$@
> +     echo "#endif" >>$@
>       echo "#ifndef C_INSTALL_CFLAGS" >>$@
>       echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) 
> $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
>       echo "#endif" >>$@
> diff --git a/Makefile.mingw b/Makefile.mingw
> index 74e9aff..4027171 100644
> --- a/Makefile.mingw
> +++ b/Makefile.mingw
> @@ -134,6 +134,9 @@ endif
>       echo #ifndef C_INSTALL_CXX >>$@
>       echo # define C_INSTALL_CXX "$(CXX_COMPILER)" >>$@
>       echo #endif >>$@
> +     echo #ifndef C_INSTALL_POSTINSTALL_PROGRAM >>$@
> +     echo # define C_INSTALL_POSTINSTALL_PROGRAM "$(POSTINSTALL_PROGRAM)" 
> >>$@
> +     echo #endif" >>$@
>       echo #ifndef C_INSTALL_RC_COMPILER >>$@
>       echo # define C_INSTALL_RC_COMPILER "$(RC_COMPILER)" >>$@
>       echo #endif >>$@
> diff --git a/csc.scm b/csc.scm
> index 935687f..0d34178 100644
> --- a/csc.scm
> +++ b/csc.scm
> @@ -61,6 +61,7 @@
> (define-foreign-variable CSC_PROGRAM c-string "C_CSC_PROGRAM")
> (define-foreign-variable WINDOWS_SHELL bool "C_WINDOWS_SHELL")
> (define-foreign-variable BINARY_VERSION int "C_BINARY_VERSION")
> +(define-foreign-variable POSTINSTALL_PROGRAM c-string 
> "C_INSTALL_POSTINSTALL_PROGRAM")
> 
> 
> ;;; Parameters:
> @@ -522,7 +523,7 @@ EOF
>     (set! compile-options (append pic-options '("-DC_SHARED") 
> compile-options))
>     (set! link-options
>       (cons (cond
> -             (osx (if lib "-dynamiclib" "-bundle"))
> +             (osx (if lib "-dynamiclib" "-bundle 
> -headerpad_max_install_names"))
>              (else "-shared")) link-options))
>     (set! shared #t) )
> 
> @@ -936,7 +937,7 @@ EOF
>     (when (and osx (or (not cross-chicken) host-mode))
>       (command
>        (string-append
> -     "install_name_tool -change " libchicken ".dylib "
> +     POSTINSTALL_PROGRAM " -change " libchicken ".dylib "
>       (quotewrap 
>        (let ((lib (string-append libchicken ".dylib")))
>          (if deployed
> diff --git a/defaults.make b/defaults.make
> index 4a0f238..943dc88 100644
> --- a/defaults.make
> +++ b/defaults.make
> @@ -358,6 +358,9 @@ endif
>       echo "#ifndef C_INSTALL_RC_COMPILER" >>$@
>       echo "# define C_INSTALL_RC_COMPILER \"$(RC_COMPILER)\"" >>$@
>       echo "#endif" >>$@
> +     echo "#ifndef C_INSTALL_POSTINSTALL_PROGRAM" >>$@
> +     echo "# define C_INSTALL_POSTINSTALL_PROGRAM 
> \"$(POSTINSTALL_PROGRAM)\"" >>$@
> +     echo "#endif" >>$@
>       echo "#ifndef C_INSTALL_CFLAGS" >>$@
>       echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) 
> $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
>       echo "#endif" >>$@
> -- 
> 1.7.12.4 (Apple Git-37)
> 
> _______________________________________________
> Chicken-hackers mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-hackers




reply via email to

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