Discussion:
[PATCH 0/3] Fixes to allow compilation with GCC 7
(too old to reply)
William Cohen
2017-02-01 19:01:46 UTC
Permalink
Raw Message
Fedora rawhide has preliminary version GCC 7 in it now. Some changes
in the OProfile source code were required to get oprofile to compile
with this newer compiler. The three patches in this series are
designed to address the warnings reported by the newer GCC compiler.

William Cohen (3):
Factor out multiple definitions of PPC64_ARCH and avoid non-portable
defined use
Fix OProfile libabi issues reported by GCC 7
Correct a conditional check for ff_linenr_info

libabi/abi.cpp | 2 +-
libabi/abi.h | 2 +-
libabi/opimport.cpp | 6 +++---
libop/op_cpu_type.c | 6 ------
libop/op_cpu_type.h | 8 ++++++++
libpe_utils/op_pe_utils.h | 6 ------
libperf_events/operf_utils.h | 7 +------
libpp/format_output.cpp | 2 +-
8 files changed, 15 insertions(+), 24 deletions(-)
--
2.9.3
William Cohen
2017-02-01 19:01:47 UTC
Permalink
Raw Message
When compiling oprofile with preliminary versions of GCC 7 the
compiler would warn about PPC64_ARCH define non-portable use of
"defined". The OProfile make file compiler flags settings treats
warning as errors and stops the build.

The PPC64_ARCH was defined in three different places. They have been
consolidated into a single define and the PPC64_ARCH define has been
rewritten in to avoid the non-portable use

Signed-off-by: William Cohen <***@redhat.com>
---
libop/op_cpu_type.c | 6 ------
libop/op_cpu_type.h | 8 ++++++++
libpe_utils/op_pe_utils.h | 6 ------
libperf_events/operf_utils.h | 7 +------
4 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
index 0e1f6e4..3d3c9c8 100644
--- a/libop/op_cpu_type.c
+++ b/libop/op_cpu_type.c
@@ -27,12 +27,6 @@
#include "op_cpu_type.h"
#include "op_hw_specific.h"

-/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
- * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
- * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
- */
-#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
-
struct cpu_descr {
char const * pretty;
char const * name;
diff --git a/libop/op_cpu_type.h b/libop/op_cpu_type.h
index 8d2badd..78eb9bc 100644
--- a/libop/op_cpu_type.h
+++ b/libop/op_cpu_type.h
@@ -108,6 +108,14 @@ typedef enum {
MAX_CPU_TYPE
} op_cpu;

+/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
+ * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
+ * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
+ */
+#if defined(HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
+#define PPC64_ARCH 1
+#endif
+
/**
* the CPU lowest common denominator
*
diff --git a/libpe_utils/op_pe_utils.h b/libpe_utils/op_pe_utils.h
index 3a4eb38..a790d91 100644
--- a/libpe_utils/op_pe_utils.h
+++ b/libpe_utils/op_pe_utils.h
@@ -26,12 +26,6 @@
#define OP_MAX_EVENTS 24
#define CALLGRAPH_MIN_COUNT_SCALE 15

-/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
- * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
- * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
- */
-#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
-
// Candidates for refactoring of operf
namespace op_pe_utils {

diff --git a/libperf_events/operf_utils.h b/libperf_events/operf_utils.h
index 32954cc..8afdbc2 100644
--- a/libperf_events/operf_utils.h
+++ b/libperf_events/operf_utils.h
@@ -21,6 +21,7 @@
#include "config.h"
#include "op_config.h"
#include "op_types.h"
+#include "op_cpu_type.h"
#include "operf_event.h"
#include <signal.h>

@@ -47,12 +48,6 @@ extern bool throttled;

#define OP_MAX_EVENTS 24

-/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
- * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
- * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
- */
-#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
-
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
--
2.9.3
William Cohen
2017-02-01 19:01:48 UTC
Permalink
Raw Message
GCC 7 uses the C++11 standards and dynamic exception specification are
deprecated. Spelling out what exception the method throws would cause
GCC 7 to warn about this deprecated use and the make compiler setting
woudl cause the build to fail on the warning.

Also needed to explicitly pass in a couple parameters for the abi need
method as strings rather than char * pointers to get the code to
compile with GCC 7.

Signed-off-by: William Cohen <***@redhat.com>
---
libabi/abi.cpp | 2 +-
libabi/abi.h | 2 +-
libabi/opimport.cpp | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libabi/abi.cpp b/libabi/abi.cpp
index 04a6b2d..607c7bf 100644
--- a/libabi/abi.cpp
+++ b/libabi/abi.cpp
@@ -35,7 +35,7 @@ abi::abi()
}


-int abi::need(string const key) const throw (abi_exception)
+int abi::need(string const key) const
{
if (slots.find(key) != slots.end())
return slots.find(key)->second;
diff --git a/libabi/abi.h b/libabi/abi.h
index 8b63e7f..4552160 100644
--- a/libabi/abi.h
+++ b/libabi/abi.h
@@ -29,7 +29,7 @@ class abi {
public:
abi();

- int need(std::string const key) const throw (abi_exception);
+ int need(std::string const key) const;

bool operator==(abi const & other) const;
friend std::ostream & operator<<(std::ostream & o, abi const & abi);
diff --git a/libabi/opimport.cpp b/libabi/opimport.cpp
index c2234fe..44084ae 100644
--- a/libabi/opimport.cpp
+++ b/libabi/opimport.cpp
@@ -77,8 +77,8 @@ void extractor::extract(T & targ, void const * src_,
char const * sz, char const * off)
{
unsigned char const * src = static_cast<unsigned char const *>(src_)
- + theabi.need(off);
- size_t nbytes = theabi.need(sz);
+ + theabi.need(string(off));
+ size_t nbytes = theabi.need(string(sz));

targ = 0;
if (nbytes == 0)
@@ -109,7 +109,7 @@ void extractor::extract(T & targ, void const * src_,


void import_from_abi(abi const & abi, void const * srcv,
- size_t len, odb_t * dest) throw (abi_exception)
+ size_t len, odb_t * dest)
{
struct opd_header * head =
static_cast<opd_header *>(odb_get_data(dest));
--
2.9.3
William Cohen
2017-02-01 19:01:49 UTC
Permalink
Raw Message
The GCC 7 compiler pointed out that the enum value ff_linenr_info was
being checked as a boolean by itself. The ff_linenr_info enum is a
bit flag used to check whether a particular bit in the flags variable
is set. This conditional was corrected to match other uses of
ff_linenr_info in format_output.cpp.

Signed-off-by: William Cohen <***@redhat.com>
---
libpp/format_output.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libpp/format_output.cpp b/libpp/format_output.cpp
index 11cd396..a36128f 100644
--- a/libpp/format_output.cpp
+++ b/libpp/format_output.cpp
@@ -793,7 +793,7 @@ output_symbol_details(symbol_entry const * symb,
field_datum datum(*symb, it->second, 0, c,
extra_found_images, 0.0);
output_attribute(str, datum, ff_vma, VMA);
- if (ff_linenr_info) {
+ if (flags & ff_linenr_info) {
string sym_file;
size_t sym_line;
string samp_file;
--
2.9.3
Loading...