[master] 2967f01ed param: Add a new cc_warnings parameter
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Jan 3 14:13:05 UTC 2022
commit 2967f01eda99cbafa8e224ac05b9d673cdb91f87
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Mon Dec 6 18:16:07 2021 +0100
param: Add a new cc_warnings parameter
With a new %w expansion in the cc_command parameter.
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index f2d2f0f7e..93a9989de 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -233,6 +233,7 @@ void mgt_vcl_startup(struct cli *, const char *vclsrc, const char *origin,
int mgt_push_vcls(struct cli *, unsigned *status, char **p);
const char *mgt_has_vcl(void);
extern char *mgt_cc_cmd;
+extern char *mgt_cc_warn;
extern const char *mgt_vcl_path;
extern const char *mgt_vmod_path;
#define MGT_VCC(t, n, cc) extern t mgt_vcc_ ## n;
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index faedb803b..0229e0cbc 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -63,6 +63,7 @@ struct vcc_priv {
};
char *mgt_cc_cmd;
+char *mgt_cc_warn;
const char *mgt_vcl_path;
const char *mgt_vmod_path;
#define MGT_VCC(t, n, cc) t mgt_vcc_ ## n;
@@ -150,6 +151,9 @@ run_cc(void *priv)
case 'o':
VSB_cat(sb, VGC_LIB);
break;
+ case 'w':
+ VSB_cat(sb, mgt_cc_warn);
+ break;
case '%':
VSB_putc(sb, '%');
break;
diff --git a/bin/varnishtest/tests/c00109.vtc b/bin/varnishtest/tests/c00109.vtc
new file mode 100644
index 000000000..9574d151d
--- /dev/null
+++ b/bin/varnishtest/tests/c00109.vtc
@@ -0,0 +1,9 @@
+varnishtest "cc_command and cc_warnings"
+
+varnish v1 -cliok {param.set debug +vcl_keep}
+varnish v1 -cliok {param.set cc_command "! printf '%w' >world"}
+varnish v1 -cliok {param.set cc_warnings hello}
+
+varnish v1 -errvcl "VCL compilation failed" "backend be none;"
+
+shell -expect hello "cat v1/vcl_*/world"
diff --git a/configure.ac b/configure.ac
index 87ae96a9f..e3ead6bd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -806,26 +806,33 @@ else
*-*-solaris*)
case $PTHREAD_CC in
*gcc*)
- VCC_CC="$PTHREAD_CC $OCFLAGS $WFLAGS $PTHREAD_CFLAGS -fpic -shared -o %o %s"
+ VCC_CC="$PTHREAD_CC $OCFLAGS %w $PTHREAD_CFLAGS -fpic -shared -o %o %s"
break
;;
*cc)
- VCC_CC="$PTHREAD_CC $OCFLAGS $WFLAGS -errwarn=%all,no%E_STATEMENT_NOT_REACHED $PTHREAD_CFLAGS -Kpic -G -o %o %s"
+ VCC_CC="$PTHREAD_CC $OCFLAGS %w -errwarn=%all,no%E_STATEMENT_NOT_REACHED $PTHREAD_CFLAGS -Kpic -G -o %o %s"
;;
esac
;;
*-*-darwin*)
- VCC_CC="exec cc $OCFLAGS $WFLAGS -dynamiclib -Wl,-undefined,dynamic_lookup -o %o %s"
+ VCC_CC="exec cc $OCFLAGS %w -dynamiclib -Wl,-undefined,dynamic_lookup -o %o %s"
;;
*)
- VCC_CC="exec $PTHREAD_CC $OCFLAGS $WFLAGS $PTHREAD_CFLAGS $SAN_CFLAGS -fpic -shared -Wl,-x -o %o %s"
+ VCC_CC="exec $PTHREAD_CC $OCFLAGS %w $PTHREAD_CFLAGS $SAN_CFLAGS -fpic -shared -Wl,-x -o %o %s"
;;
esac
fi
+if test "$ac_cv_env_VCC_WARN_set" = set; then
+ VCC_WARN=$ac_cv_env_VCC_WARN_value
+else
+ VCC_WARN=$WFLAGS
+fi
+
OCFLAGS="$OCFLAGS $WFLAGS"
AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code])
+AC_DEFINE_UNQUOTED([VCC_WARN],"$VCC_WARN",[C compiler warnings for VCL code])
# Stupid automake needs this
VTC_TESTS="$(cd $srcdir/bin/varnishtest && echo tests/*.vtc)"
diff --git a/include/tbl/params.h b/include/tbl/params.h
index 964c2d255..8b82b97f1 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -1533,7 +1533,20 @@ PARAM_STRING(
"Command used for compiling the C source code to a "
"dlopen(3) loadable object. Any occurrence of %s in "
"the string will be replaced with the source file name, "
- "and %o will be replaced with the output file name.",
+ "%o will be replaced with the output file name, and %w "
+ "will be replaced by the cc_warnings parameter.",
+ /* flags */ MUST_RELOAD
+)
+
+PARAM_STRING(
+ /* name */ cc_warnings,
+ /* tweak */ tweak_string,
+ /* priv */ &mgt_cc_warn,
+ /* def */ VCC_WARN,
+ /* descr */
+ "Warnings used when compiling the C source code with "
+ "the cc_command parameter. By default, VCL is compiled "
+ "with the same set of warnings as Varnish itself.",
/* flags */ MUST_RELOAD
)
More information about the varnish-commit
mailing list