Forum: Ruby-core [ruby-trunk - Bug #8762][Open] CFLAGS and LDFLAGS are not set properly in Makefile when they are alr

F736999f7c1b7a87a100faa112bbc0f3?d=identicon&s=25 charliesome (Charlie Somerville) (Guest)
on 2013-08-09 12:36
(Received via mailing list)
Issue #8762 has been reported by charliesome (Charlie Somerville).

----------------------------------------
Bug #8762: CFLAGS and LDFLAGS are not set properly in Makefile when they
are already set as environment variables
https://bugs.ruby-lang.org/issues/8762

Author: charliesome (Charlie Somerville)
Status: Open
Priority: High
Assignee:
Category:
Target version:
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


When the environment variable CFLAGS does not exist, running the
./configure script outputs this to the Makefile:

    # ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS = ${cflags} $(ARCH_FLAG)

However, setting the environment variable CFLAGS to anything (even the
empty string) causes ${cflags} to not be included in the CFLAGS written
to the Makefile:

    # CFLAGS= ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS =  $(ARCH_FLAG)

The same happens with LDFLAGS. I believe this is what is breaking trunk
compilation for both myself and spastorino in #8759.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-08-09 15:52
(Received via mailing list)
Issue #8762 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Rejected
Priority changed from High to Low

No, it's not the culprit.
----------------------------------------
Bug #8762: CFLAGS and LDFLAGS are not set properly in Makefile when they
are already set as environment variables
https://bugs.ruby-lang.org/issues/8762#change-41043

Author: charliesome (Charlie Somerville)
Status: Rejected
Priority: Low
Assignee:
Category:
Target version:
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


When the environment variable CFLAGS does not exist, running the
./configure script outputs this to the Makefile:

    # ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS = ${cflags} $(ARCH_FLAG)

However, setting the environment variable CFLAGS to anything (even the
empty string) causes ${cflags} to not be included in the CFLAGS written
to the Makefile:

    # CFLAGS= ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS =  $(ARCH_FLAG)

The same happens with LDFLAGS. I believe this is what is breaking trunk
compilation for both myself and spastorino in #8759.
398856ea967f3cab2dbe3df99d732069?d=identicon&s=25 tmm1 (Aman Gupta) (Guest)
on 2013-12-07 07:24
(Received via mailing list)
Issue #8762 has been updated by tmm1 (Aman Gupta).

Status changed from Rejected to Open
Assignee set to nobu (Nobuyoshi Nakada)
Priority changed from Low to Normal
Target version set to current: 2.1.0

I believe this is still a bug.

If I compile ruby with a custom CFLAGS, the build will lose all
optimization and warning flags:

$ CFLAGS="-I/opt/include " ./configure >/dev/null && make -n gc.o
gcc -I/opt/include  -D_FORTIFY_SOURCE=2 -fstack-protector
-fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE   -I.
-I.ext/include/x86_64-linux -I./include -I. -o gc.o -c gc.c

$ ./configure >/dev/null && make -n gc.o
gcc -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter
-Wno-parentheses -Wno-long-long -Wno-missing-field-initializers
-Wunused-variable -Werror=pointer-arith -Werror=write-strings
-Werror=declaration-after-statement
-Werror=implicit-function-declaration -ansi -std=iso9899:199409
-D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow
-fvisibility=hidden -DRUBY_EXPORT -fPIE   -I.
-I.ext/include/x86_64-linux -I./include -I. -o gc.o -c gc.c

This issue is resolved in my environment with the following patch:

diff --git a/Makefile.in b/Makefile.in
index 98749de..e6b82df 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -57,7 +57,7 @@ CC_VERSION = @CC_VERSION@
 OUTFLAG = @OUTFLAG@$(empty)
 COUTFLAG = @COUTFLAG@$(empty)
 ARCH_FLAG = @ARCH_FLAG@
-CFLAGS = @CFLAGS@ $(ARCH_FLAG)
+CFLAGS = $(cflags) @CFLAGS@ $(ARCH_FLAG)
 cflags = @cflags@
 optflags = @optflags@
 debugflags = @debugflags@
diff --git a/configure.in b/configure.in
index 88d24ee..99d78e4 100644
--- a/configure.in
+++ b/configure.in
@@ -852,7 +852,7 @@ if test "$GCC" = yes; then
     done
 fi

-test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval
CFLAGS="\"$cflags $ARCH_FLAG\""
+test -z "${ac_env_CFLAGS_set}" -a -n "${ARCH_FLAG+set}" && eval
CFLAGS="\"$ARCH_FLAG\""
 test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval
CXXFLAGS="\"$cxxflags $ARCH_FLAG\""

 }

----------------------------------------
Bug #8762: CFLAGS and LDFLAGS are not set properly in Makefile when they
are already set as environment variables
https://bugs.ruby-lang.org/issues/8762#change-43486

Author: charliesome (Charlie Somerville)
Status: Open
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: current: 2.1.0
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


When the environment variable CFLAGS does not exist, running the
./configure script outputs this to the Makefile:

    # ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS = ${cflags} $(ARCH_FLAG)

However, setting the environment variable CFLAGS to anything (even the
empty string) causes ${cflags} to not be included in the CFLAGS written
to the Makefile:

    # CFLAGS= ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS =  $(ARCH_FLAG)

The same happens with LDFLAGS. I believe this is what is breaking trunk
compilation for both myself and spastorino in #8759.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-12-07 09:11
(Received via mailing list)
Issue #8762 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Rejected

If you set CFLAGS, that you say it must be used.a
----------------------------------------
Bug #8762: CFLAGS and LDFLAGS are not set properly in Makefile when they
are already set as environment variables
https://bugs.ruby-lang.org/issues/8762#change-43491

Author: charliesome (Charlie Somerville)
Status: Rejected
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: current: 2.1.0
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


When the environment variable CFLAGS does not exist, running the
./configure script outputs this to the Makefile:

    # ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS = ${cflags} $(ARCH_FLAG)

However, setting the environment variable CFLAGS to anything (even the
empty string) causes ${cflags} to not be included in the CFLAGS written
to the Makefile:

    # CFLAGS= ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS =  $(ARCH_FLAG)

The same happens with LDFLAGS. I believe this is what is breaking trunk
compilation for both myself and spastorino in #8759.
398856ea967f3cab2dbe3df99d732069?d=identicon&s=25 tmm1 (Aman Gupta) (Guest)
on 2013-12-07 09:14
(Received via mailing list)
Issue #8762 has been updated by tmm1 (Aman Gupta).


With my patch, provided CFLAGS are appended to the built-in flags. This
follows the behavior most projects use with ./configure.

On trunk now, what is the correct way to add a CFLAG for build? (i.e.
-Iextra/include/dir)?
----------------------------------------
Bug #8762: CFLAGS and LDFLAGS are not set properly in Makefile when they
are already set as environment variables
https://bugs.ruby-lang.org/issues/8762#change-43492

Author: charliesome (Charlie Somerville)
Status: Rejected
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category:
Target version: current: 2.1.0
ruby -v: trunk
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


When the environment variable CFLAGS does not exist, running the
./configure script outputs this to the Makefile:

    # ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS = ${cflags} $(ARCH_FLAG)

However, setting the environment variable CFLAGS to anything (even the
empty string) causes ${cflags} to not be included in the CFLAGS written
to the Makefile:

    # CFLAGS= ./configure && grep ^CFLAGS Makefile
    ...configure output...
    CFLAGS =  $(ARCH_FLAG)

The same happens with LDFLAGS. I believe this is what is breaking trunk
compilation for both myself and spastorino in #8759.
This topic is locked and can not be replied to.