OpenWrt Forum Archive

Topic: Building on OSX 10.11 (El Capitain)

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, I'm trying to build an image (for RPi) on OSX 10.11.3 with Xcode 7.2.1
I'm using a very minimal configuration, to start out with.
The make V=s fails in build_dir/host/pkg-config-0.28 :

/usr/bin/env bash ../libtool  --tag=CC   --mode=compile ccache gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../glib -I../glib -I..  -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DGLIB_COMPILATION -DPCRE_STATIC -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/include -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/usr/include -D_REENTRANT  -O2 -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/include -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/usr/include -Wall -MT gunicollate.lo -MD -MP -MF .deps/gunicollate.Tpo -c -o gunicollate.lo gunicollate.c
libtool: compile:  ccache gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../glib -I../glib -I.. -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DGLIB_COMPILATION -DPCRE_STATIC -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/include -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/usr/include -D_REENTRANT -O2 -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/include -I/Volumes/SpunRust/OpenWRT/RPi/openwrt/staging_dir/host/usr/include -Wall -MT gunicollate.lo -MD -MP -MF .deps/gunicollate.Tpo -c gunicollate.c -o gunicollate.o
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfo.h:529:0,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:27,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:39,
                 from gunicollate.c:30:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfoDeprecated.h:1242:28: error: expected ',' or '}' before '__attribute__'
   kLSHandlerOptionsDefault       __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_4, __MAC_10_11, __IPHONE_4_0, __IPHONE_9_0, "Creator codes are deprecated on OS X.") = 0,
                            ^
In file included from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSOpen.h:181:0,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:31,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:39,
                 from gunicollate.c:30:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSOpenDeprecated.h:27:25: error: expected ',' or '}' before '__attribute__'
   kLSLaunchStartClassic         __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_11, __IPHONE_NA, __IPHONE_NA, "The Classic environment is no longer supported.") = 0x00020000, /* Does nothing.*/
                         ^

Any ideas?
Thanks, Bill.

It seems to be that pkg-config contains it's own version of glib2 and gunicollate.c from glib includes the system header <CoreServices/CoreServices.h> which contains "something funky" which gcc doesn't like.
This is gcc5 from macports choking on a system header. Macports clang3.9 is fine.
This also applies to compiling the current upstream glib2 - it fails on the same file, gunicollate.c
So, as a work-around use the macports glib2 instead of the pkg-config one by patching:

--- openwrt-orig/tools/pkg-config/Makefile    2016-01-21 18:06:07.000000000 +0000
+++ openwrt-bill/tools/pkg-config/Makefile    2016-02-03 20:44:05.000000000 +0000
@@ -19,7 +19,7 @@

unexport PKG_CONFIG

-HOST_CONFIGURE_ARGS += --with-internal-glib
+HOST_CONFIGURE_ARGS += --without-internal-glib

define Host/Install
    $(MAKE) -C $(HOST_BUILD_DIR) install

And before running make:
  export GLIB_CFLAGS="$(pkg-config --cflags glib-2.0)"
  export GLIB_LIBS="$(pkg-config --libs glib-2.0)"

I've got CC 15.05 to compile an SD image on OSX 10.11.3 using macport's gcc5.3.0 (and Xcode 7.2)


// Not sure if these are really needed.
$ sudo ln -s /usr/lib/libiconv.* /usr/local/lib
$ sudo ln -s /usr/include/openssl /usr/local/include
$ sudo touch /usr/local/include/crypt.h


// Get OpenWRT.
$ git clone git://git.openwrt.org/15.05/openwrt.git
$ cd openwrt
$ git checkout 483dac821788b457d349233e770329186a0aa860
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a


// Fix pkg-config to use macports glib2
$ cat ../pkg-config_no-glib.patch

--- openwrt-orig/tools/pkg-config/Makefile    2016-01-21 18:06:07.000000000 +0000
+++ openwrt-bill/tools/pkg-config/Makefile    2016-02-03 20:44:05.000000000 +0000
@@ -19,7 +19,7 @@

unexport PKG_CONFIG

-HOST_CONFIGURE_ARGS += --with-internal-glib
+HOST_CONFIGURE_ARGS += --without-internal-glib

define Host/Install
    $(MAKE) -C $(HOST_BUILD_DIR) install

$ patch -p1 < ../pkg-config_no-glib.patch
$ export GLIB_CFLAGS="$(pkg-config --cflags glib-2.0)"
$ export GLIB_LIBS="$(pkg-config --libs glib-2.0)"


// gcc chokes on -rdynamic
$ cat ../005-no-rdynamic.patch tools/e2fsprogs/patches

--- a/configure    2016-02-04 13:29:11.000000000 +0000
+++ b/configure    2016-02-04 13:29:46.000000000 +0000
@@ -4224,10 +4224,6 @@
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

-if test "$GCC" = yes; then
-   RDYNAMIC="-rdynamic"
-
-fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'

$ cp ../005-no-rdynamic.patch tools/e2fsprogs/patches


// gcc chokes on -no-cpp-precomp
$ cat ../202-zap-no-cpp-precomp.patch package/libs/ncurses/patches

--- a/configure    2016-02-05 12:39:11.000000000 +0000
+++ b/configure    2016-02-05 12:39:40.000000000 +0000
@@ -5584,7 +5584,7 @@
        chmod +x mk_shared_lib.sh
        ;;
    darwin*) #(vi
-        EXTRA_CFLAGS="-no-cpp-precomp"
+        EXTRA_CFLAGS=""
        CC_SHARED_OPTS="-dynamic"
        MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $@` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $@'
        test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi

$ cp ../202-zap-no-cpp-precomp.patch package/libs/ncurses/patches


// Configure it.
$ wget https://downloads.openwrt.org/chaos_cal … onfig.diff
$ mv config.diff .config
$ make oldconfig


// Stand well back.
$ make
$ ls -al bin/brcm2708/openwrt-15.05-brcm2708-bcm2708-sdcard-vfat-ext4.img

-rw-r--r-- 1 bill staff 79691776 Feb  5 13:36 bin/brcm2708/openwrt-15.05-brcm2708-bcm2708-sdcard-vfat-ext4.img

The discussion might have continued from here.