Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building the latest trunk on MacOS 10.9 #583

Closed
artynet opened this issue Feb 9, 2017 · 9 comments
Closed

building the latest trunk on MacOS 10.9 #583

artynet opened this issue Feb 9, 2017 · 9 comments

Comments

@artynet
Copy link

artynet commented Feb 9, 2017

Hello folks, I have bumped into an issue related here while building the latest trunk :

pfalcon/esp-open-sdk#236

In file included from zconf.tab.c:212:
./zconf.hash.c:34:82: error: unknown type name 'GPERF_LEN_TYPE'
static const struct kconf_id *kconf_id_lookup(register const char *str, register GPERF_LEN_TYPE len);
                                                                                 ^
./zconf.hash.c:240:44: warning: static variable 'kconf_id_strings_contents' is used in an inline function with external linkage [-Wstatic-in-inline]
              register const char *s = o + kconf_id_strings;
                                           ^
./zconf.hash.c:163:43: note: expanded from macro 'kconf_id_strings'
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
                                          ^
./zconf.hash.c:165:1: note: use 'static' to give inline function 'kconf_id_lookup' internal linkage
__inline
^
static
./zconf.hash.c:126:40: note: 'kconf_id_strings_contents' declared here
static const struct kconf_id_strings_t kconf_id_strings_contents =
                                       ^
1 warning and 1 error generated.
gmake[2]: *** [Makefile:90: zconf.tab.o] Error 1
gmake[1]: *** [Makefile:168: build-lib-kconfig] Error 2
gmake: *** [Makefile:128: build] Error 2

I usually have also to apply this patch to make properly build the source and make it working after the build :

diff --git a/kconfig/Makefile b/kconfig/Makefile
index ee838aa3..bc4ab087 100644
--- a/kconfig/Makefile
+++ b/kconfig/Makefile
@@ -6,9 +6,9 @@ all: conf mconf nconf
        @true   # Just be silent, you fscking son of a fscking beach...

 # Build flags
-CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" \
-        -DGPERF_LEN_TYPE="$(gperf_len_type)"
-LDFLAGS = $(INTL_LIBS)
++CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" \
+        -DGPERF_LEN_TYPE="$(gperf_len_type)" -I/opt/local/include -std=gnu89
++LDFLAGS = -L/opt/local/lib -lintl $(INTL_LIBS)

 # Compiler flags to use gettext
 ifeq ($(gettext),)
diff --git a/scripts/functions b/scripts/functions
index 9f852b39..c8c88f16 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -572,7 +572,7 @@ CT_DoForceRmdir() {
                 mode="$(stat -c '%a' "$(dirname "${dir}")")"
                 ;;
             Darwin|*BSD)
-                mode="$(stat -f '%Lp' "$(dirname "${dir}")")"
+                mode="$(stat -f '%a' "$(dirname "${dir}")")"
                 ;;
             *)
                 CT_Abort "Unhandled host OS $CT_SYS_OS"

of course I have already installed and set in my PATH the GNU tools before the native ones :

sudo port -v install git gsed gawk gperf grep gettext wget libtool autoconf automake

gperf installed version is v3.0.4 and it should bring any issue while compiling....any help would be appreciated.

Best, Arturo

@stilor
Copy link
Contributor

stilor commented Feb 9, 2017

It appears you didn't re-run bootstrap after pulling new changes from the trunk. configure.ac has changed, you need to regenerate (and obviously, re-run) configure. This should obviate the first part of your patch.

As to the second part - could you explain what was the problem? The solution is incorrect for at least BSD - this makes it print access time instead of access permissions. Judging from macos manpage for stat(1) [I don't have a macos], it is incorrect for macos as well.

@artynet
Copy link
Author

artynet commented Feb 9, 2017

hello @stilor, I am pretty sure I run :

$ make distclean
$ ./bootstrap

before running ./configure, but I'll double-check tomorrow. As far a concerns the second part, it deals with the gnu stat command in a peculiar way on osx :

http://developers-club.com/posts/186124/

so we have to apply it so not to get a stat error just after the cross-build starts.

Best, Arturo

@stilor
Copy link
Contributor

stilor commented Feb 9, 2017

Re 2nd part of the patch: the command in your patch does not match the one in the link you posted. Note that in the link, they also changed -f into -c. Apparently, macos may use either BSD-style stat, or GNU stat. So the right solution would be to check the type of the stat in configure and use that one for macos.

The current form of the patch will break BSD systems (well, they are not exactly supported right now, but I hope to add such support).

@artynet
Copy link
Author

artynet commented Feb 10, 2017

ok, i have figured it out. First of all I need to build binutils from source and copy the three tools :

objdump
objcopy
readelf
strip

to /usr/local/bin so to have them system-wide. Then, reworking the above patch 👍

diff --git a/kconfig/Makefile b/kconfig/Makefile
index ee838aa3..1d1976a5 100644
--- a/kconfig/Makefile
+++ b/kconfig/Makefile
@@ -10,6 +10,13 @@ CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(VERSION)\"" \
         -DGPERF_LEN_TYPE="$(gperf_len_type)"
 LDFLAGS = $(INTL_LIBS)

+# add additional cflags and ldflags for macports build
+UNAME_S := $(shell uname -s)
+ifeq ($(UNAME_S),Darwin)
+CFLAGS += -I/opt/local/include -std=gnu89
+LDFLAGS += -L/opt/local/lib -lintl
+endif
+
 # Compiler flags to use gettext
 ifeq ($(gettext),)
 INTL_CFLAGS = -Wno-format-security -DKBUILD_NO_NLS
diff --git a/scripts/functions b/scripts/functions
index 9f852b39..cb0aafad 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -571,9 +571,12 @@ CT_DoForceRmdir() {
             Linux|CYGWIN*)
                 mode="$(stat -c '%a' "$(dirname "${dir}")")"
                 ;;
-            Darwin|*BSD)
+            *BSD)
                 mode="$(stat -f '%Lp' "$(dirname "${dir}")")"
                 ;;
+            Darwin)
+                mode="$(stat -f '%a' "$(dirname "${dir}")")"
+                ;;
             *)
                 CT_Abort "Unhandled host OS $CT_SYS_OS"
                 ;;

then, after successfully built and installed the source, I have added this entry to the paths.mk file :

export stat=/usr/bin/stat

and this entry to the paths.sh file :

export stat="/usr/bin/stat"

and then build nicely start and complete. My intention is to keep these changes locally from time to time when I need to build the toolchains...thank you again for your support !

@tsjk
Copy link

tsjk commented Feb 10, 2017

The patch should say

+            Darwin)
+                mode="$(stat -c '%a' "$(dirname "${dir}")")"
+                ;;

No? Given a GNU stat.

@tsjk
Copy link

tsjk commented Feb 10, 2017

And the other tools can be pointed out at configure time. I have MacPorts and do:

                GREP=/opt/local/bin/grep \
                INSTALL=/opt/local/bin/ginstall \
                LIBTOOL=/opt/local/bin/glibtool \
                LIBTOOLIZE=/opt/local/bin/glibtoolize \
                M4=/opt/local/bin/gm4 \
                MAKE=/opt/local/bin/gmake \
                OBJCOPY=/opt/local/bin/gobjcopy \
                OBJDUMP=/opt/local/bin/gobjdump \
                READELF=/opt/local/bin/greadelf \
                SED=/opt/local/bin/gsed \
                ./configure --prefix=/opt/local --mandir=/opt/local/man/ --infodir=/opt/local/share/info --datadir=/opt/local/share --sysconfdir=/opt/local/etc --localstatedir=/opt/local/var/lib --libdir=/opt/local/lib && \
                make

@stilor
Copy link
Contributor

stilor commented Feb 11, 2017

Which is what I said, we should make a check for stat(1) in configure.

@artynet
Copy link
Author

artynet commented Feb 11, 2017

@stilor I totally agree with this.

@tsjk any hints why the bottom entries in the menu are not highlighted as they should ? take a look at this screenshot :

screenshot_312

I have to "walk blind" through the menus. I'm pretty sure is a ncurses issue but I can't get rid of it...any pointers about it ?

@stilor
Copy link
Contributor

stilor commented Feb 28, 2017

stat selection should be solved by #594

@stilor stilor closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants