Skip to content

Commit 484a2fd

Browse files
authored
Remove PIE flag from compilation commands in generated makefiles (#619)
1 parent 73cd88f commit 484a2fd

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

server/src/building/CompileCommand.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ namespace utbot {
105105
});
106106
}
107107

108+
void CompileCommand::removeFPIE() {
109+
CollectionUtils::erase_if(commandLine, [](const std::string &arg) {
110+
return StringUtils::startsWith(arg, "-fPIE");
111+
});
112+
}
113+
108114
void CompileCommand::initOutput() {
109115
auto it = findOutput();
110116
if (it != commandLine.end()) {

server/src/building/CompileCommand.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ namespace utbot {
4646
void removeIncludeFlags();
4747

4848
void removeWerror();
49+
50+
void removeFPIE();
4951
};
5052
}
5153

server/src/printers/NativeMakefilePrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ namespace printer {
256256
compileCommand.addFlagsToBegin(
257257
CompilationUtils::getCoverageCompileFlags(primaryCompilerName));
258258
compileCommand.addFlagsToBegin(SanitizerUtils::getSanitizeCompileFlags(compilerName));
259+
compileCommand.removeFPIE();
259260

260261
fs::path temporaryDependencyFile = getTemporaryDependencyFile(sourcePath);
261262
fs::path dependencyFile = getDependencyFile(sourcePath);
@@ -327,6 +328,7 @@ namespace printer {
327328
}
328329
testCompilationCommand.addFlagToBegin(FPIC_FLAG);
329330
testCompilationCommand.addFlagsToBegin(SANITIZER_NEEDED_FLAGS);
331+
testCompilationCommand.removeFPIE();
330332

331333
fs::path testSourcePath = Paths::sourcePathToTestPath(testGen->projectContext, sourcePath);
332334
fs::path compilationDirectory = compilationUnitInfo->getDirectory();

0 commit comments

Comments
 (0)