pfalcon / esp-open-sdk

Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips
1.97k stars 622 forks source link

Problem building on OS X, possibly related to Xcode 6.3 (6D570) #45

Open jgarbers opened 9 years ago

jgarbers commented 9 years ago

Trying to build on OS X 10.10.3 this morning after getting an Xcode update last night. Working from a clean clone of the repository and building with make STANDALONE=n the process fails with this error:

[INFO ]  Installing pass-2 core C compiler
[ERROR]    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstddef:46:9: error: no member named 'ptrdiff_t' in the global namespace
[ERROR]    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:402:13: error: unknown type name 'ptrdiff_t'

and many more _ptrdifft related errors until the build ends with

[ERROR]    fatal error: too many errors emitted, stopping now [-ferror-limit=]
[ERROR]    make[4]: *** [graphite.o] Error 1
[ERROR]    make[4]: *** [graphite-blocking.o] Error 1
[ERROR]    make[3]: *** [all-gcc] Error 2
[ERROR]   
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing pass-2 core C compiler'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@216]
[ERROR]  >>        called from: do_cc_core_backend[scripts/build/cc/gcc.sh@483]
[ERROR]  >>        called from: do_cc_core_pass_2[scripts/build/cc/gcc.sh@153]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@638]

Not sure if this is related to the recent Xcode update or if something completely different is happening.

leonprou commented 9 years ago

Same error here, any solution?

Also, I choose STANDALONE=y

hebnern commented 9 years ago

I struggled with this all weekend as well. I tried all sorts of things, but could not get anything to work. I finally resorted to just downgrading to 6.1.1 and it is now working again. To do this, uninstall Xcode by deleting it from /Applications/ and completely uninstall the Command Line Tools with:

cd /
lsbom -fls /var/db/receipts/com.apple.pkg.CLTools_Executables.bom | sudo xargs -I{} rm -rf "{}"
lsbom -fls /var/db/receipts/com.apple.pkg.DevSDK_OSX109.bom | sudo xargs -I{} rm -rf "{}"
lsbom -fls /var/db/receipts/com.apple.pkg.DevSDK_OSX1010.bom | sudo xargs -I{} rm -rf "{}"
sudo rm /var/db/receipts/com.apple.pkg.{CLTools_Executables,DevSDK_OSX109,DevSDK_OSX1010}.{bom,plist}

source

Then I downloaded and installed the "Command Line Tools (OS X 10.10) for Xcode 6.1.1" from Apple. I also tried CLT 6.2, but it had the same problem as 6.3.

idserda commented 9 years ago

Probably not the best solution, but this makes it compile:

In esp-open-sdk/crosstool-NG/.build/src/gcc-4.8.2/gcc, add this line somewhere at the top:

#include <stddef.h>

of the following files:

graphite.c 
graphite-blocking.c 
graphite-clast-to-gimple.c
graphite-dependences.c 
graphite-interchange.c 
graphite-optimize-isl.c 
graphite-poly.c 
graphite-scop-detection.c 
graphite-sese-to-poly.c
georgkreimer commented 9 years ago

@idserda that worked! Thanks!

jgarbers commented 9 years ago

Worked for me as well -- thanks, @idserda ! -- but I'm unclear about under what circumstances the changes to those files might be lost, since they're not in this repo -- I guess they get downloaded during the build process. Would make clean blow away those changes? I hesitate to experiment for fear of having to do them over again...

murf0 commented 9 years ago

in gmp.h at : ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in remove __need_size_t define and undef Source: http://stackoverflow.com/questions/17417978/compiling-gmp-library-on-osx-10-9-with-c-enabled I did it after a failed build-attempt and a make clean x2 TNTKY!

jgarbers commented 9 years ago

@murf0 are you saying that fix works without making the changes to the graphite files @idserda mentioned?

murf0 commented 9 years ago

@jgarbers Yes, sorry was a bit unclear in the description. Basically the issue is with GMP library and the latest Xcode. This change forces the import of ptrdiff_t.

sebgiles commented 9 years ago

I'm also having this issue, but cannot apply @idserda's nor @murf0's fix, I don't understand what files they are talking about, there is no ".build" directory inside of "crosstool-NG" in this project, please point me in the right direction! I'm kind of a noob here, so please forgive anything stupid I might have said, I really have no idea where to look, thank you.

Tylerflick commented 9 years ago

@sebgiles The .build directory is created when you run make.

Here are the steps to build if you are hitting this wall:

  1. Pull the repo.
  2. Execute make. (You'll see the above error)
  3. Perform the edit listed by @murf0.
  4. Execute make clean && make.
sebgiles commented 9 years ago

@Tylerflick Thanks I'll try it now! Intuitively I deleted the whole thing and downloaded it again, it feels odd that I can't fix the build error before it actually occurs.

murf0 commented 9 years ago

That's because the first build-process downloads and kickstarts the secondary build-processes needed. So before the first try there is no source to build, the sources are downloaded.

pacovar commented 9 years ago

@murf0 Beauty, thanks.

anusoft commented 9 years ago

from @idserda comment I've added command line for lazy people like me

gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-blocking.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-clast-to-gimple.c
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-dependences.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-interchange.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-optimize-isl.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-poly.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-scop-detection.c 
gsed -i '1s/^/#include <stddef.h>\n/' crosstool-NG/.build/src/gcc-4.8.2/gcc/graphite-sese-to-poly.c
Anton-Rodionov commented 9 years ago

@anusoft Thanks, it works!

jiegec commented 9 years ago

@pfalcon I think we should include the solution from @anusoft in the README.md for Mac OS X users.

pfalcon commented 9 years ago

Any crosstool-NG patches should go to crosstool-NG project.

Palantir555 commented 9 years ago

Thanks, @murf0! That worked like a charm.

For reference, this is the sed command I use to fix the issue using murf0's method:

sed -i '/__need_size_t/d' ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in

whmountains commented 9 years ago

@Palantir555 Thanks so much. Your one-liner fixed it for me on Mac OS 10.10.

joostn commented 9 years ago

Somehow that sed command failed when I tried, but this worked for me: sed -i.bak '/__need_size_t/d' ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in

austimbo commented 9 years ago

A big thank you for this post. Commenting out "__need_size_t define and undef" did the job for me. I was going to be lost without it.

zdrc commented 8 years ago

I'm trying to build on OSX 10.11.1 with Xcode 7.1 and I'm running into an identical problem but these fixes aren't working.

First of all, "__need_size_t define and undef" is not in ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in

What is in ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in is

#define __need_size_t  /* tell gcc stddef.h we only want size_t */
#if defined (__cplusplus)
#include <cstddef>     /* for size_t */
#else
#include <stddef.h>    /* for size_t */
#endif
#undef __need_size_t

I've removed this section of code, ran make clean 2x, then make again to no avail. This code always reappears in gmp-h.in after running make. I've also tried the sed commands of @anusoft, and that hasn't worked either. Any suggestions?

Edit: I thought it'd be useful to say that my error output is identical to what is described by OP.

Palantir555 commented 8 years ago

@zdrc You're not supposed to remove that whole block of code, but just the first and last lines (#define __need_size_t /*...*/ and #undef __need_size_t). Try going back to the original file and removing those 2 lines, and let us know if that fixes your issue.

zdrc commented 8 years ago

I just deleted #define __need_size_t and #undef __need_size_t, ran make clean 2 x, and attempted to build again. It failed with the same error message.

Should I expect not too see those lines in the gmp-h.in after deleting, cleaning, and rebuilding?

Palantir555 commented 8 years ago

@zdrc the file you are modifying is downloaded during the make process (before erroring out).

You should run the sed command I posted and run make again right away. Do NOT run make clean after seeing the error.

By running make clean you are removing the file you just modified, then when you run make you download the original version again and see the same error because you've got the same file.

Hope that helps :)

zdrc commented 8 years ago

@Palantir555 OK, I'll give that a go. Unfortunately, it seems like http://www.mpfr.org is down today, so I can't build at the moment.

recursify commented 8 years ago

@zdrc Yep mpfr and isl packages are unreachable.

Download these alternate links into esp-open-sdk/crosstool-NG/.build/tarballs

http://pkgs.fedoraproject.org/repo/pkgs/gcc/isl-0.12.2.tar.bz2/e039bfcfb6c2ab039b8ee69bf883e824/isl-0.12.2.tar.bz2 https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.xz

zdrc commented 8 years ago

@Palantir555 I did as you suggested and it built.

@recursify Earlier today I changed the shell script that was fetching mpfr to get the package from http://ftp.gnu.org/gnu/mpfr/ instead. I didn't have a problem with isl while building.

Thanks all

kalanda commented 8 years ago

Both solutions (@anusoft and @murf0) did work for me using OSX 10.11.1 (15B42). Thanks

eyp commented 8 years ago

Xcode 7.1.1 on OSX 10.11.1 works like a charm with the @murf0 patch, doing a 'make' afterwards. Remember, don't do a 'make clean' after patching.

Tkizzy commented 8 years ago

@Tylerflick is trolling.

Pull the repo.
Execute make. (You'll see the above error)
Perform the edit listed by @murf0.
Execute make clean && make.

DO NOT DO A MAKE CLEAN AFTER THE EDIT! IT WILL ERASE THE EDIT AND YOU'LL HAVE TO DO IT AGAIN.

instead just make after doing the edit.

jacobjennings commented 8 years ago

if you don't have gsed, brew install gnu-sed ln -s /usr/local/Cellar/gnu-sed/4.2.2/bin/sed ~/bin/gsed assuming ~/bin is already in your path.

mcauser commented 8 years ago

The @murf0 patch works on Xcode 7.2 (7C68) on OSX 10.10.5 Yosemite. ./crosstool-NG/.build/src/gmp-5.1.3/gmp-h.in //#define __need_size_t //#undef __need_size_t