Skip to content

Commit

Permalink
Correct linker flags when building with qbs 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Gatzka committed Aug 30, 2016
1 parent c127342 commit 712c1a6
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions qbs/hardening.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,33 @@ Product {
}
return defines;
}
cpp.cFlags: {

cpp.driverFlags: {
var flags = [];
if (product.enableHardening) {
var toolchain = qbs.toolchain[0];
var compilerVersion = cpp.compilerVersionMajor + "." + cpp.compilerVersionMinor + "." + cpp.compilerVersionPatch;
if (((toolchain === "gcc") && (Versions.versionIsAtLeast(compilerVersion, "4.9"))) ||
((toolchain === "clang") && (Versions.versionIsAtLeast(compilerVersion, "3.5")))) {
//flags.push("-fstack-protector-strong", "-fpie");
flags.push("-fstack-protector-strong", "-fpie");
}
if (toolchain === "gcc") {
//flags.push("-pie");
flags.push("-pie");
}
}
return flags;
}

cpp.linkerFlags: {
var flags = [];
if (product.enableHardening) {
var toolchain = qbs.toolchain[0];
var compilerVersion = cpp.compilerVersionMajor + "." + cpp.compilerVersionMinor + "." + cpp.compilerVersionPatch;
if (((toolchain === "gcc") && (Versions.versionIsAtLeast(compilerVersion, "4.9"))) ||
((toolchain === "clang") && (Versions.versionIsAtLeast(compilerVersion, "3.5")))) {
flags.push("-z relro now");
//flags.push("-pie");
//flags.push("-fpie","-pie");
//flags.push("-fpie","-pie");
// if (qbs.buildVariant.contains("release")) {
// flags.push("-D_FORTIFY_SOURCE=2");
// }
flags.push("-z","relro");
flags.push("-z","now");
flags.push("-z","noexecstack");
}
}
return flags;
Expand Down

0 comments on commit 712c1a6

Please sign in to comment.