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

use $CC if it's set externally #10041

Closed
catawbasam opened this issue Feb 3, 2015 · 17 comments
Closed

use $CC if it's set externally #10041

catawbasam opened this issue Feb 3, 2015 · 17 comments
Labels
building Build system, or building Julia or its dependencies

Comments

@catawbasam
Copy link
Contributor

Getting the following after checking out master just now and running make clean all on 64-bit red hat linux:

CC src/llvm-simdloop.o
CC src/gc.o
gc.c:40: error: flexible array member in otherwise empty struct
make[2]: *** [gc.o] Error 1
make[1]: *** [julia-release] Error 2
make: *** [release] Error 2

@tkelman
Copy link
Contributor

tkelman commented Feb 3, 2015

Previously reported at #9984 - the fix there is kind of ugly, and we're going to be increasing the minimum GCC version requirement on 0.4 before too much longer. I'd recommend you install and start using the devtoolset to get a modern version of GCC.

@catawbasam
Copy link
Contributor Author

[keithc@giada julia]$ echo $CC
/usr/depot/gcc-4.8.2

This is too old?

@tkelman
Copy link
Contributor

tkelman commented Feb 3, 2015

No, not at all, 4.8.2 is fine. Are you sure that's the gcc that is getting used to build julia?

@ihnorton ihnorton added the building Build system, or building Julia or its dependencies label Feb 3, 2015
@nalimilan
Copy link
Member

I guess you ended up using the system gcc for some reason. I did the same mistake before I filed #9984.

Can you run make VERBOSE=1 to see the actual command that is run? Maybe our handling of CC is broken. FWIW, for the RPMs I'm using devtoolset-2 and I just run this command before make to set the required environment variables: /opt/rh/devtoolset-2/enable.

@catawbasam
Copy link
Contributor Author

If the Makefile is using $CC, then it is 4.8.2. If Makefile ever references gcc directly then it will pick up gcc 4.4.

The release 0.3 branch builds fine. Only master has the problem.

Thank you for the tip re devtoolset. Unfortunately, on my fairly locked down system:
/opt/rh/devtoolset-2/enable
bash: /opt/rh/devtoolset-2/enable: No such file or directory

alias gcc="/usr/depot/gcc-4.8.2" Does not help

@nalimilan
Copy link
Member

@catawbasam Please post the output of make VERBOSE=1.

@catawbasam
Copy link
Contributor Author

[keithc@giada julia]$ git branch
* master
  release-0.3
[keithc@giada julia]$ make VERBOSE=1
make[1]: Entering directory `/devel/asias/keithc/giada/julia'
make[2]: Entering directory `/devel/asias/keithc/giada/julia/deps'
make[2]: Leaving directory `/devel/asias/keithc/giada/julia/deps'
make[2]: Entering directory `/devel/asias/keithc/giada/julia/src'
 gcc -m64  "-DJL_SYSTEM_IMAGE_PATH=\"../lib/julia/sys.ji\"" -DJULIA_TARGET_ARCH=native -std=gnu99 -pipe -fPIC -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -DCOPY_STACKS -O3 -ggdb3 -falign-functions -momit-leaf-frame-pointer -D_GNU_SOURCE -Iflisp -Isupport -I/devel/asias/keithc/giada/julia/usr/include -I/devel/asias/keithc/giada/julia/deps/libuv/include -I/devel/asias/keithc/giada/julia/usr/include -DLIBRARY_EXPORTS -I. -I/devel/asias/keithc/giada/julia/deps/valgrind -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fvisibility=hidden -fno-common -DNDEBUG -c gc.c -o gc.o
gc.c:40: error: flexible array member in otherwise empty struct
make[2]: *** [gc.o] Error 1
make[2]: Leaving directory `/devel/asias/keithc/giada/julia/src'
make[1]: *** [julia-release] Error 2
make[1]: Leaving directory `/devel/asias/keithc/giada/julia'
make: *** [release] Error 2
[keithc@giada julia]$ 

@nalimilan
Copy link
Member

Clearly we're calling the system gcc here. And yet src/Makefile looks correct:

$(BUILDDIR)/%.o: %.c $(HEADERS) | $(BUILDDIR)
        @$(call PRINT_CC, $(CC) $(CPPFLAGS) $(CFLAGS) $(SHIPFLAGS) -DNDEBUG -c $< -o $@)

Could try replacing all occurrences of gcc in Make.inc with the path to your gcc and see if that works?

@catawbasam
Copy link
Contributor Author

Yes, that did work.

@catawbasam
Copy link
Contributor Author

I'd like to have it use my CC environment variable instead.
However that led to a circular reference error Make.inc lines 278-281:

CC_BASE = $(CROSS_COMPILE)/usr/depot/gcc-4.8.2/bin/gcc
CXX_BASE = $(CROSS_COMPILE)g++
CC = $(CC_BASE)
CXX = $(CXX_BASE)

@nalimilan
Copy link
Member

Can you identify the precise place where replacing gcc with the correct path makes a difference? Is changing CC_BASE enough?

@catawbasam
Copy link
Contributor Author

Yes, changing CC_BASE is enough. Looks like several of the other gcc references are in if-then branches that may not be exercised when I make.

@nalimilan
Copy link
Member

OK, thanks. That CC_BASE = $(CROSS_COMPILE)gcc line indeed hardcodes the gcc command, which doesn't look right at all. I think we should always respect CC when it is set, and only use that line when it's missing.

@catawbasam
Copy link
Contributor Author

Sounds great. Thanks!

@tkelman
Copy link
Contributor

tkelman commented Feb 3, 2015

That line is a workaround for cmake not playing well with ccache. But yeah we should probably check whether CC is set before hard-coding that variable.

@JeffBezanson JeffBezanson changed the title gc.c:40: error: flexible array member in otherwise empty struct use $CC if it's set externally Feb 3, 2015
@nalimilan
Copy link
Member

@tkelman What's the issue with CMake exactly? Can we pass it an absolute path to the compiler when CC is defined?

@tkelman
Copy link
Contributor

tkelman commented Feb 5, 2015

See the libgit2 PR's. The issue is Julia's makefiles do some really ugly bad-idea things with appending flags (-m32 for 32-bit compilation from 64-bit Linux, and a set of OSX-specific flags) to CC. I proposed to fix that, because cmake requires the compiler argument to be a path, not including any flags. But rather than add a new variable to hold the flags, which was a more invasive change and there was concern that I didn't catch every usage (all the dependencies, etc), I came up with this simpler workaround using CC_BASE. We could try an alternate approach, sending only the first word of CC to cmake, but be careful that it doesn't break USE_CCACHE.

tkelman added a commit that referenced this issue Apr 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies
Projects
None yet
Development

No branches or pull requests

4 participants