-Wno-logical-op-parentheses -Wno-msvc-include -Wno-invalid-source-encoding -Wno-unknown-pragmas \
-Wno-unused-command-line-argument");
}
+
+ ARG_ENABLE("sanitizer", "Enable address sanitizer extension", "no");
+ if (PHP_SANITIZER == "yes") {
+ if (COMPILER_NUMERIC_VERSION < 500) {
+ ERROR("Clang at least 5.0.0 required for sanitation plugins");
+ }
+ add_asan_opts("CFLAGS", "LIBS", "LDFLAGS");
+ }
}
ARG_WITH("codegen-arch", "Architecture for code generation: ia32, sse, sse2, avx, avx2", "no");
MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname + " $(BUILD_DIR)\\" + manifest_name);
}
+ var is_lib = makefiletarget.match(new RegExp("\\.lib$"));
if (makefiletarget.match(new RegExp("\\.dll$"))) {
ldflags = "/dll $(LDFLAGS)";
manifest = "-@$(_VC_MANIFEST_EMBED_DLL)";
- } else if (makefiletarget.match(new RegExp("\\.lib$"))) {
+ } else if (is_lib) {
ldflags = "$(ARFLAGS)";
ld = "@$(MAKE_LIB)";
} else {
manifest = "-@$(_VC_MANIFEST_EMBED_EXE)";
}
+ if (PHP_SANITIZER == "yes") {
+ if (CLANG_TOOLSET) {
+ add_asan_opts("CFLAGS_" + SAPI, "LIBS_" + SAPI, (is_lib ? "ARFLAGS_" : "LDFLAGS_") + SAPI);
+ }
+ }
+
if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
// Add compiler and link flags if PGO options are selected
if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
}
}
}
+ if (PHP_SANITIZER == "yes") {
+ if (CLANG_TOOLSET) {
+ extra_path = extra_path + ";" + get_clang_lib_dir() + "\\windows";
+ }
+ }
MF.WriteLine("set-tmp-env:");
MF.WriteLine(" @set PATH=" + extra_path + ";$(PATH)");
}
}
+function get_clang_lib_dir()
+{
+ var ret = null;
+ var ver = null;
+
+ if (COMPILER_NAME.match(/clang version ([\d\.]+) \((.*)\)/)) {
+ ver = RegExp.$1;
+ } else {
+ ERROR("Faled to determine clang lib path");
+ }
+
+ /* FIXME existence check, etc. */
+ if (X64) {
+ ret = PROGRAM_FILES + "\\LLVM\\lib\\clang\\" + ver + "\\lib";
+ } else {
+ ret = PROGRAM_FILESx86 + "\\LLVM\\lib\\clang\\" + ver + "\\lib";
+ }
+
+ return ret;
+}
+
+function add_asan_opts(cflags_name, libs_name, ldflags_name)
+{
+
+ var ver = null;
+
+ if (COMPILER_NAME.match(/clang version ([\d\.]+) \((.*)\)/)) {
+ ver = RegExp.$1;
+ } else {
+ ERROR("Faled to determine clang lib path");
+ }
+
+ if (!!cflags_name) {
+ ADD_FLAG(cflags_name, "-fsanitize=address");
+ }
+ if (!!libs_name) {
+ if (X64) {
+ ADD_FLAG(libs_name, "clang_rt.asan_dynamic-x86_64.lib clang_rt.asan_dynamic_runtime_thunk-x86_64.lib");
+ } else {
+ ADD_FLAG(libs_name, "clang_rt.asan_dynamic-i386.lib clang_rt.asan_dynamic_runtime_thunk-i386.lib");
+ }
+ }
+
+ if (!!ldflags_name) {
+ ADD_FLAG(ldflags_name, "/libpath:\"" + get_clang_lib_dir() + "\\windows\"");
+ }
+}
+