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

Update Linux makefile to allow compilation with GCC 7.3 #1921

Merged
merged 1 commit into from
May 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions buildenv/docker/jdk11/x86_64/ubuntu16/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,4 @@ RUN cd /root \
ENV JAVA_HOME="/root/bootjdk10"
ENV PATH="${JAVA_HOME}/bin:${PATH}"

# The below CFLAG prevents "error: inline function ${FUNCTION_NAME} declared but never defined [-Werror]"
ENV CFLAGS="-fgnu89-inline"

WORKDIR /root
12 changes: 11 additions & 1 deletion runtime/makelib/targets.mk.linux.inc.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<#--
Copyright (c) 1998, 2017 IBM Corp. and others
Copyright (c) 1998, 2018 IBM Corp. and others

This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -153,6 +153,16 @@ ifdef USE_PPC_GCC
endif
</#if>

<#-- GCC versions greater than 5 default to GNU11 but OpenJ9 uses
GNU89 inline semantics. -fgnu89-inline option is appended to CFLAGS
to allow compilation with GCC versions greater than 5 and GNU89 inline
semantics. Reference - https://gcc.gnu.org/gcc-5/porting_to.html.
-->
GCCVERSIONGTEQ5 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when gcc 10 ships? (Not a blocker for merging this now but something to think about while we're looking at this or we'll have to rediscover it later)

Copy link
Contributor Author

@babsingh babsingh May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. gcc -dumpversion | cut -f1 -d. will evaluate to 10
  2. expr 10 \>= 5 will evaluate to 1
  3. GCCVERSIONGTEQ5 = 1
  4. if GCCVERSIONGTEQ5 == 1 then CFLAGS+=-fgnu89-inline

We want to use -fgnu89-inline for GCC versions >= 5 since they will default to GNU11 semantics.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread the cut command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be invoking gcc, but instead checking if we're using the gcc toolchain and only then invoking $(CC) -dumpversion. A system has at most one tool called 'gcc', but the user may have configured their build to use a different version; the test should be based on the selected compiler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put together a PR to address my previous comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks @keithc-ca

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @keithc-ca

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2205 proposes a fix for this.

ifeq "$(GCCVERSIONGTEQ5)" "1"
CFLAGS+=-fgnu89-inline
endif

<#if !uma.spec.processor.ppc>
CXXFLAGS+=-fno-exceptions -fno-rtti -fno-threadsafe-statics
<#else>
Expand Down