* Re: [PATCH 1/2] Enable C++
@ 2015-04-07 15:27 Mark Wielaard
0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2015-04-07 15:27 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]
On Fri, 2015-04-03 at 23:40 +0200, Petr Machata wrote:
> Mark Wielaard <mjw@redhat.com> writes:
> > Why is that mkdir now necessary?
>
> It's not, but I thought it's a good idea for symmetry. The reason the
> c++ bits need this mkdir is that we keep that code in a sub-directory,
> and this creates the corresponding sub-directory for the dependency
> tracking helper files.
Aha, ok thanks.
> >> +AC_CACHE_CHECK([for working C++ compiler], ac_cv_cxx_works,
> >> +[AC_LANG_PUSH([C++])
> >> + AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
> >> +struct foo {
> >> + int i;
> >> + explicit foo () : i (0) {}
> >> + virtual ~foo () {}
> >> +};])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)
> >> + AC_LANG_POP()])
> >> +AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
> >
> > We require gnu++98 above.
> > Is the explicit enough to make sure the compiler supports C++98?
>
> Well, this is a C++98 code. It's of course not enough to test the whole
> C++98--the language is vast. The reason for that test is that I want to
> make sure we really do have a C++ compiler. AC_PROG_CXX happily exports
> CXX even if none is available, so we can't use that in conditionals.
I was mostly wondering whether we needed to add an command line argument
like -std=gnu++98 to be sure. But maybe that is all implicit and
standard for all gcc versions anyway.
Cheers,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Enable C++
@ 2015-04-14 14:47 Mark Wielaard
0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2015-04-14 14:47 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 256 bytes --]
On Tue, 2015-04-14 at 16:37 +0200, Petr Machata wrote:
> I think this was mostly agreed on. The change since last time is that
> we pass -std=gnu++98 when testing C++ compiler existence, for
> correctness' sake.
Yes, looks fine.
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Enable C++
@ 2015-04-14 14:37 Petr Machata
0 siblings, 0 replies; 7+ messages in thread
From: Petr Machata @ 2015-04-14 14:37 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 4608 bytes --]
Hi there,
I think this was mostly agreed on. The change since last time is that
we pass -std=gnu++98 when testing C++ compiler existence, for
correctness' sake.
Thanks,
Petr
--- 8< -----------------------------------------------------------
- Detect C++ compiler in configure, add supporting infrastructure to
eu.am.
Signed-off-by: Petr Machata <pmachata@redhat.com>
---
ChangeLog | 4 ++++
config/ChangeLog | 6 ++++++
config/eu.am | 21 ++++++++++++++++++++-
configure.ac | 28 ++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 5c8e1c2..65c3ef5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-14 Petr Machata <pmachata@redhat.com>
+
+ * configure.ac (HAVE_CXX): New conditional.
+
2015-03-13 Mark Wielaard <mjw@redhat.com>
* configure.ac (ac_cv_c99): Add explicit return.
diff --git a/config/ChangeLog b/config/ChangeLog
index 586ebb0..936f62d 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-14 Petr Machata <pmachata@redhat.com>
+
+ * eu.am (AM_CXXFLAGS, CXXCOMPILE.os): New variables.
+ (%.os: %.c %.o): Create dep-file subdirectory if necessary.
+ (%.os: %.cc %.o): New rule.
+
2015-03-18 Petr Machata <pmachata@redhat.com>
* known-dwarf.awk (comment): Drop all uses of this variable.
diff --git a/config/eu.am b/config/eu.am
index faf8add..f1d290b 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -1,6 +1,6 @@
## Common automake fragments for elfutils subdirectory makefiles.
##
-## Copyright (C) 2010, 2014 Red Hat, Inc.
+## Copyright (C) 2010, 2014, 2015 Red Hat, Inc.
##
## This file is part of elfutils.
##
@@ -35,11 +35,17 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
$(if $($(*F)_no_Werror),,-Werror) \
$(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
$($(*F)_CFLAGS)
+AM_CXXFLAGS = -std=gnu++98 -Wall -Wshadow -Wformat=2 \
+ $(if $($(*F)_no_Werror),,-Werror) \
+ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+ $($(*F)_CXXFLAGS)
COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
+CXXCOMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(CXXCOMPILE))
%.os: %.c %.o
if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
@@ -50,6 +56,19 @@ else
$(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
endif
+%.os: %.cc %.o
+if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
+ if $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
+ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
+ rm -f "$(DEPDIR)/$*.Tpo"; \
+ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ fi
+else
+ $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
+endif
+
CLEANFILES = *.gcno *.gcda
textrel_msg = echo "WARNING: TEXTREL found in '$@'"
diff --git a/configure.ac b/configure.ac
index c4b818d..6d1df60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ AS_IF([test "$use_locks" = yes],
AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
AC_PROG_CC
+AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AM_PROG_LEX
@@ -89,6 +90,33 @@ CFLAGS="$old_CFLAGS"])
AS_IF([test "x$ac_cv_c99" != xyes],
AC_MSG_ERROR([gcc with C99 support required]))
+AC_LANG_PUSH([C++])
+
+# Above, we check for C++ compiler. However even if none is available,
+# CXX is set to a non-empty value. So we need to figure out whether a
+# C++ compiler is actually available.
+
+# We in fact use -std=gnu++98. Check that the compiler supports this.
+SAVE_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS="$CXXFLAGS -std=gnu++98"
+
+AC_CACHE_CHECK([for C++ compiler that supports -std=gnu++98],
+ ac_cv_cxx_works,
+[AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+struct foo {
+ int i;
+ explicit foo () : i (0) {}
+ virtual ~foo () {}
+};
+
+struct A { int i; int j; } a = {.i = 1, .j = 2};
+])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)])
+
+CXXFLAGS="$SAVE_CXXFLAGS"
+AC_LANG_POP()
+
+AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
+
AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
# Use the same flags that we use for our DSOs, so the test is representative.
# Some old compiler/linker/libc combinations fail some ways and not others.
--
2.1.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Enable C++
@ 2015-04-07 17:10 Petr Machata
0 siblings, 0 replies; 7+ messages in thread
From: Petr Machata @ 2015-04-07 17:10 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 880 bytes --]
Mark Wielaard <mjw@redhat.com> writes:
> I was mostly wondering whether we needed to add an command line argument
> like -std=gnu++98 to be sure. But maybe that is all implicit and
> standard for all gcc versions anyway.
Actually I can't find code that c++98 mode would reject and gnu++98
would allow. -pedantic makes all the difference, and it makes it
regardless of the dialect chosen.
Which makes it kinda hard to actually test for gnu++98 support. Which I
think we formally need, for all the GNU C stuff that we get in C headers
((struct X) {blah, blah}, long long literals, __VA_ARGS__). But GCC
happily compiles that in c++98 mode anyway.
So, I don't know. Maybe I just compile the test case with -std=gnu++98
and make it "Checking for working C++ compiler that accepts -std=gnu++98"?
Clang knows about the option as well, FWIW.
Thanks,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Enable C++
@ 2015-04-03 21:40 Petr Machata
0 siblings, 0 replies; 7+ messages in thread
From: Petr Machata @ 2015-04-03 21:40 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1693 bytes --]
Mark Wielaard <mjw@redhat.com> writes:
> On Fri, 2015-04-03 at 10:28 +0200, Petr Machata wrote:
>> - Detect C++ compiler in configure, add supporting infrastructure to
>> eu.am.
>
> Looks good. Two questions below, but not blockers. Just curious.
>
>> index faf8add..f1d290b 100644
>> --- a/config/eu.am
>> +++ b/config/eu.am
>> [...]
>> %.os: %.c %.o
>> if AMDEP
>> + test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
>> if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
>> -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
>> then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
>
> Why is that mkdir now necessary?
It's not, but I thought it's a good idea for symmetry. The reason the
c++ bits need this mkdir is that we keep that code in a sub-directory,
and this creates the corresponding sub-directory for the dependency
tracking helper files.
>> +AC_CACHE_CHECK([for working C++ compiler], ac_cv_cxx_works,
>> +[AC_LANG_PUSH([C++])
>> + AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
>> +struct foo {
>> + int i;
>> + explicit foo () : i (0) {}
>> + virtual ~foo () {}
>> +};])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)
>> + AC_LANG_POP()])
>> +AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
>
> We require gnu++98 above.
> Is the explicit enough to make sure the compiler supports C++98?
Well, this is a C++98 code. It's of course not enough to test the whole
C++98--the language is vast. The reason for that test is that I want to
make sure we really do have a C++ compiler. AC_PROG_CXX happily exports
CXX even if none is available, so we can't use that in conditionals.
Thanks,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Enable C++
@ 2015-04-03 11:33 Mark Wielaard
0 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2015-04-03 11:33 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]
On Fri, 2015-04-03 at 10:28 +0200, Petr Machata wrote:
> - Detect C++ compiler in configure, add supporting infrastructure to
> eu.am.
Looks good. Two questions below, but not blockers. Just curious.
> index faf8add..f1d290b 100644
> --- a/config/eu.am
> +++ b/config/eu.am
> [...]
> %.os: %.c %.o
> if AMDEP
> + test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
> if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
> -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
> then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
Why is that mkdir now necessary?
> +AC_CACHE_CHECK([for working C++ compiler], ac_cv_cxx_works,
> +[AC_LANG_PUSH([C++])
> + AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
> +struct foo {
> + int i;
> + explicit foo () : i (0) {}
> + virtual ~foo () {}
> +};])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)
> + AC_LANG_POP()])
> +AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
We require gnu++98 above.
Is the explicit enough to make sure the compiler supports C++98?
Thanks,
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Enable C++
@ 2015-04-03 8:28 Petr Machata
0 siblings, 0 replies; 7+ messages in thread
From: Petr Machata @ 2015-04-03 8:28 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 4076 bytes --]
- Detect C++ compiler in configure, add supporting infrastructure to
eu.am.
Signed-off-by: Petr Machata <pmachata@redhat.com>
---
ChangeLog | 4 ++++
config/ChangeLog | 6 ++++++
config/eu.am | 21 ++++++++++++++++++++-
configure.ac | 15 +++++++++++++++
4 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 5c8e1c2..6c6f216 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-18 Petr Machata <pmachata@redhat.com>
+
+ * configure.ac (HAVE_CXX): New conditional.
+
2015-03-13 Mark Wielaard <mjw@redhat.com>
* configure.ac (ac_cv_c99): Add explicit return.
diff --git a/config/ChangeLog b/config/ChangeLog
index 586ebb0..32f3c93 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-02 Petr Machata <pmachata@redhat.com>
+
+ * eu.am (AM_CXXFLAGS, CXXCOMPILE.os): New variables.
+ (%.os: %.c %.o): Create dep-file subdirectory if necessary.
+ (%.os: %.cc %.o): New rule.
+
2015-03-18 Petr Machata <pmachata@redhat.com>
* known-dwarf.awk (comment): Drop all uses of this variable.
diff --git a/config/eu.am b/config/eu.am
index faf8add..f1d290b 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -1,6 +1,6 @@
## Common automake fragments for elfutils subdirectory makefiles.
##
-## Copyright (C) 2010, 2014 Red Hat, Inc.
+## Copyright (C) 2010, 2014, 2015 Red Hat, Inc.
##
## This file is part of elfutils.
##
@@ -35,11 +35,17 @@ AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
$(if $($(*F)_no_Werror),,-Werror) \
$(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
$($(*F)_CFLAGS)
+AM_CXXFLAGS = -std=gnu++98 -Wall -Wshadow -Wformat=2 \
+ $(if $($(*F)_no_Werror),,-Werror) \
+ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+ $($(*F)_CXXFLAGS)
COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
+CXXCOMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(CXXCOMPILE))
%.os: %.c %.o
if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
@@ -50,6 +56,19 @@ else
$(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
endif
+%.os: %.cc %.o
+if AMDEP
+ test -d $(DEPDIR)/$(*D) || mkdir $(DEPDIR)/$(*D)
+ if $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
+ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
+ rm -f "$(DEPDIR)/$*.Tpo"; \
+ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ fi
+else
+ $(CXXCOMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
+endif
+
CLEANFILES = *.gcno *.gcda
textrel_msg = echo "WARNING: TEXTREL found in '$@'"
diff --git a/configure.ac b/configure.ac
index c4b818d..bc40bff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ AS_IF([test "$use_locks" = yes],
AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
AC_PROG_CC
+AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AM_PROG_LEX
@@ -89,6 +90,20 @@ CFLAGS="$old_CFLAGS"])
AS_IF([test "x$ac_cv_c99" != xyes],
AC_MSG_ERROR([gcc with C99 support required]))
+# Above, we check for C++ compiler. However even if none is available,
+# CXX is set to a non-empty value. So we need to figure out whether a
+# C++ compiler is actually available.
+AC_CACHE_CHECK([for working C++ compiler], ac_cv_cxx_works,
+[AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl
+struct foo {
+ int i;
+ explicit foo () : i (0) {}
+ virtual ~foo () {}
+};])], ac_cv_cxx_works=yes, ac_cv_cxx_works=no)
+ AC_LANG_POP()])
+AM_CONDITIONAL(HAVE_CXX, test "$ac_cv_cxx_works" = yes)
+
AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
# Use the same flags that we use for our DSOs, so the test is representative.
# Some old compiler/linker/libc combinations fail some ways and not others.
--
2.1.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-04-14 14:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 15:27 [PATCH 1/2] Enable C++ Mark Wielaard
-- strict thread matches above, loose matches on Subject: below --
2015-04-14 14:47 Mark Wielaard
2015-04-14 14:37 Petr Machata
2015-04-07 17:10 Petr Machata
2015-04-03 21:40 Petr Machata
2015-04-03 11:33 Mark Wielaard
2015-04-03 8:28 Petr Machata
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).