public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Provide macro NO_WERROR to disable -Werror for backend compiling.
@ 2018-08-06  6:36 Yichun Zhang (agentzh)
  2018-08-23 23:39 ` [PATCH] Pass -Wno-tautological-compare when building kernel modules and dyninst DSO Yichun Zhang (agentzh)
  0 siblings, 1 reply; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-06  6:36 UTC (permalink / raw)
  To: systemtap; +Cc: Yichun Zhang (agentzh)

Currently we always turn on -Werror when compiling the kernel module and
the dyninst DSO. This causes compile-time errors when the user input stap
scripts contain inefficiencies like `a == a` or `a != a`, which can be
common for automatically generated stap code from naive tools.

Now we can build systemtap with `./configure CXXFLAGS='-DNO_WERROR'` to
disable the -Werror option for the kernel and dyninst backends (the bpf
backend is not applicable here).
---
 buildrun.cxx | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/buildrun.cxx b/buildrun.cxx
index 59b9e88ca..41ea3d021 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -34,7 +34,11 @@ extern "C" {
 // A bit of obfuscation for Gentoo's sake.
 // We *need* -Werror for stapconf to work correctly.
 // https://bugs.gentoo.org/show_bug.cgi?id=522908
+#ifndef NO_WERROR
 #define WERROR ("-W" "error")
+#else
+#define WERROR ("-W" "no-error")
+#endif
 
 #define PATH_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+,-./_"
 
-- 
2.11.0.295.gd7dffce

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] Pass -Wno-tautological-compare when building kernel modules and dyninst DSO
  2018-08-06  6:36 [PATCH] Provide macro NO_WERROR to disable -Werror for backend compiling Yichun Zhang (agentzh)
@ 2018-08-23 23:39 ` Yichun Zhang (agentzh)
  2018-08-24  0:58   ` Yichun Zhang (agentzh)
  0 siblings, 1 reply; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-23 23:39 UTC (permalink / raw)
  To: systemtap; +Cc: Yichun Zhang (agentzh)

Currently we always turn on -Wall and -Werror when compiling the kernel
module and the dyninst DSO. This causes compile-time errors when the user
input stap scripts contain inefficiencies like `a == a` or `a != a`, which
can be common for automatically generated stap code from naive tools.
---
 buildrun.cxx                                  |  5 +-
 testsuite/systemtap.base/tautological_cmp.exp | 78 +++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 2 deletions(-)
 create mode 100644 testsuite/systemtap.base/tautological_cmp.exp

diff --git a/buildrun.cxx b/buildrun.cxx
index 0e94ebcbd..79b355123 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -222,7 +222,7 @@ compile_dyninst (systemtap_session& s)
       "gcc", "--std=gnu99", s.translated_source, "-o", module,
       "-fvisibility=hidden", "-O2", "-I" + s.runtime_path, "-D__DYNINST__",
       "-Wall", WERROR, "-Wno-unused", "-Wno-strict-aliasing",
-      "-pthread", "-lrt", "-fPIC", "-shared",
+      "-Wno-tautological-compare", "-pthread", "-lrt", "-fPIC", "-shared",
     };
 
   // BZ855981/948279.  Since dyninst/runtime.h includes __sync_* calls,
@@ -507,7 +507,8 @@ compile_pass (systemtap_session& s)
   o << "EXTRA_CFLAGS += $(call cc-option,-fno-ipa-icf)" << endl;
 
   // Assumes linux 2.6 kbuild
-  o << "EXTRA_CFLAGS += -Wno-unused " << WERROR << endl;
+  o << "EXTRA_CFLAGS += -Wno-unused -Wno-tautological-compare " << WERROR
+    << endl;
   #if CHECK_POINTER_ARITH_PR5947
   o << "EXTRA_CFLAGS += -Wpointer-arith" << endl;
   #endif
diff --git a/testsuite/systemtap.base/tautological_cmp.exp b/testsuite/systemtap.base/tautological_cmp.exp
new file mode 100644
index 000000000..a1bbd8b1f
--- /dev/null
+++ b/testsuite/systemtap.base/tautological_cmp.exp
@@ -0,0 +1,78 @@
+set test "tautological_cmp"
+set testpath "$srcdir/$subdir"
+
+if {! [installtest_p]} { untested "$test"; return }
+
+# --- TEST 1 ---
+
+set subtest1 "TEST 1: q == q"
+foreach runtime [get_runtime_list] {
+    if {$runtime eq ""} { set runtime "kernel" }
+    set test_name "$subtest1 ($runtime)"
+
+    set cmd "stap -e 'probe begin \{ a = 32; println (a == a); exit() \}' --runtime=$runtime"
+    send_log "executing: $cmd\n"
+    set pipe [open "| sh -c {$cmd}" r]
+    set out [read $pipe]
+    set is_err 0
+    if {[catch {close $pipe} stderr] != 0} { set is_err 1 }
+
+    set exp_out "1\n"
+    regsub -all -- {\n} $exp_out {\n} escaped_exp_out
+    if {$out eq $exp_out} {
+        pass "${test_name}: stdout matches \"$escaped_exp_out\""
+    } else {
+        fail "${test_name}: stdout fails to match \"$escaped_exp_out\": got \"$out\""
+    }
+
+    if {$is_err} {
+        fail "${test_name}: exit code not zero"
+    } else {
+        pass "${test_name}: exit code is zero"
+    }
+
+    set no_stderr_pat "-W(?:error=)?tautological-compare\\y"
+    regsub -all -- {\n} $no_stderr_pat {\n} escaped_no_stderr_pat
+    if {[regexp -linestop -- $no_stderr_pat $stderr]} {
+        fail "${test_name}: stderr should NOT match \"$escaped_no_stderr_pat\" but got \"$stderr\""
+    } else {
+        pass "${test_name}: stderr should NOT matches \"$escaped_no_stderr_pat\""
+    }
+}
+
+# --- TEST 2 ---
+
+set subtest2 "TEST 2: q != q"
+foreach runtime [get_runtime_list] {
+    if {$runtime eq ""} { set runtime "kernel" }
+    set test_name "$subtest2 ($runtime)"
+
+    set cmd "stap -e 'probe begin \{ a = 32; println (a != a); exit() \}' --runtime=$runtime"
+    send_log "executing: $cmd\n"
+    set pipe [open "| sh -c {$cmd}" r]
+    set out [read $pipe]
+    set is_err 0
+    if {[catch {close $pipe} stderr] != 0} { set is_err 1 }
+
+    set exp_out "0\n"
+    regsub -all -- {\n} $exp_out {\n} escaped_exp_out
+    if {$out eq $exp_out} {
+        pass "${test_name}: stdout matches \"$escaped_exp_out\""
+    } else {
+        fail "${test_name}: stdout fails to match \"$escaped_exp_out\": got \"$out\""
+    }
+
+    if {$is_err} {
+        fail "${test_name}: exit code not zero"
+    } else {
+        pass "${test_name}: exit code is zero"
+    }
+
+    set no_stderr_pat "-W(?:error=)?tautological-compare\\y"
+    regsub -all -- {\n} $no_stderr_pat {\n} escaped_no_stderr_pat
+    if {[regexp -linestop -- $no_stderr_pat $stderr]} {
+        fail "${test_name}: stderr should NOT match \"$escaped_no_stderr_pat\" but got \"$stderr\""
+    } else {
+        pass "${test_name}: stderr should NOT matches \"$escaped_no_stderr_pat\""
+    }
+}
-- 
2.11.0.295.gd7dffce

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Pass -Wno-tautological-compare when building kernel modules and dyninst DSO
  2018-08-23 23:39 ` [PATCH] Pass -Wno-tautological-compare when building kernel modules and dyninst DSO Yichun Zhang (agentzh)
@ 2018-08-24  0:58   ` Yichun Zhang (agentzh)
  0 siblings, 0 replies; 3+ messages in thread
From: Yichun Zhang (agentzh) @ 2018-08-24  0:58 UTC (permalink / raw)
  To: systemtap

Hello!

On Thu, Aug 23, 2018 at 4:39 PM, Yichun Zhang (agentzh)
<agentzh@gmail.com> wrote:
> Currently we always turn on -Wall and -Werror when compiling the kernel
> module and the dyninst DSO. This causes compile-time errors when the user
> input stap scripts contain inefficiencies like `a == a` or `a != a`, which
> can be common for automatically generated stap code from naive tools.

Just committed to master with the green light from fche on IRC.

Best,
Yichun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-24  0:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06  6:36 [PATCH] Provide macro NO_WERROR to disable -Werror for backend compiling Yichun Zhang (agentzh)
2018-08-23 23:39 ` [PATCH] Pass -Wno-tautological-compare when building kernel modules and dyninst DSO Yichun Zhang (agentzh)
2018-08-24  0:58   ` Yichun Zhang (agentzh)

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).