Take parameters -pic -pie from commandline.

This commit is contained in:
Christoffer Lerno
2021-05-13 15:30:57 +02:00
parent 460c0d04d7
commit 3b0a2579e8
3 changed files with 38 additions and 1 deletions

View File

@@ -269,6 +269,38 @@ static void parse_option(BuildOptions *options)
return;
}
FAIL_WITH_ERR("Unknown debug argument -%s.", &current_arg[1]);
case 'f':
if (match_shortopt("fpie"))
{
options->pie = PIE_SMALL;
return;
}
if (match_shortopt("fPIE"))
{
options->pie = PIE_BIG;
return;
}
if (match_shortopt("fno-pie"))
{
options->pie = PIE_NONE;
return;
}
if (match_shortopt("fpic"))
{
options->pic = PIC_SMALL;
return;
}
if (match_shortopt("fPIC"))
{
options->pic = PIC_BIG;
return;
}
if (match_shortopt("fno-pic"))
{
options->pic = PIC_NONE;
return;
}
FAIL_WITH_ERR("Unknown argument -%s.", &current_arg[1]);
case 'h':
break;
case 'O':
@@ -421,6 +453,8 @@ BuildOptions parse_arguments(int argc, const char *argv[])
.debug_info_override = DEBUG_INFO_NOT_SET,
.safe_mode = -1,
.command = COMMAND_MISSING,
.pie = PIE_DEFAULT,
.pic = PIC_DEFAULT,
.files = NULL
};
for (int i = DIAG_NONE; i < DIAG_WARNING_TYPE; i++)

View File

@@ -173,6 +173,8 @@ typedef struct BuildOptions_
unsigned version;
CompilerCommand command;
CompileOption compile_option;
PieGeneration pie;
PicGeneration pic;
DiagnosticsSeverity severity[DIAG_END_SENTINEL];
OptimizationSetting optimization_setting_override;
DebugInfo debug_info_override;
@@ -186,7 +188,6 @@ typedef struct BuildOptions_
typedef enum
{
TARGET_TYPE_EXECUTABLE,

View File

@@ -82,6 +82,8 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
{
target->arch_os_target = options->arch_os_target_override;
}
if (options->pie != PIE_DEFAULT) target->pie = options->pie;
if (options->pic != PIC_DEFAULT) target->pic = options->pic;
target->emit_llvm = options->emit_llvm;
switch (options->compile_option)
{