From 7eb6be5a2cdbd9d57ac4adb71348701f9139e709 Mon Sep 17 00:00:00 2001 From: Maxim Ganetsky Date: Fri, 24 Nov 2023 02:18:36 +0300 Subject: [PATCH] IDE: pass to FPC only documented assembler mode parameter values and only for relevant CPU families (i8086, i386, x86_64), issue #38786 --- components/codetools/definetemplates.pas | 8 ++++++++ ide/compileroptions.pp | 12 ++++++------ ide/frames/compiler_config_target.pas | 2 +- ide/frames/compiler_parsing_options.pas | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 036d680882..975f9e4ad3 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -1120,6 +1120,8 @@ function GetFPCSubtarget(Subtarget: string): string; // normalize function IsPas2jsTargetOS(TargetOS: string): boolean; function IsPas2jsTargetCPU(TargetCPU: string): boolean; +function IsCPUX86(TargetCPU: string): boolean; + function IsCTExecutable(AFilename: string; out ErrorMsg: string): boolean; // not thread-safe function GuessPascalCompilerFromExeName(Filename: string): TPascalCompiler; // thread-safe @@ -4027,6 +4029,12 @@ begin Result:=PosI('ecmascript',TargetCPU)>0; end; +function IsCPUX86(TargetCPU: string): boolean; +begin + TargetCPU:=GetFPCTargetCPU(TargetCPU); + Result:=(TargetCPU='i8086') or (TargetCPU='i386') or (TargetCPU='x86_64'); +end; + function IsCTExecutable(AFilename: string; out ErrorMsg: string): boolean; begin Result:=false; diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 279301948a..a48ff59bd1 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -2721,12 +2721,12 @@ begin { --------------- Parsing Tab ------------------- } - { Assembler reading style -Ratt = AT&T -Rintel = Intel -Rdirect = direct } - case AssemblerStyle of - 1: Result.Add('-Rintel'); - 2: Result.Add('-Ratt'); - 3: Result.Add('-Rdirect'); - end; + { Assembler reading style -Ratt = AT&T -Rintel = Intel -Rdefault (or no option) = default } + if IsCPUX86(CurTargetCPU) then + case AssemblerStyle of + 1: Result.Add('-Rintel'); + 2: Result.Add('-Ratt'); + end; // Syntax Options GetSyntaxOptions(Kind,Result); diff --git a/ide/frames/compiler_config_target.pas b/ide/frames/compiler_config_target.pas index f3d9844b5b..e806ad450e 100644 --- a/ide/frames/compiler_config_target.pas +++ b/ide/frames/compiler_config_target.pas @@ -255,7 +255,7 @@ begin // Update selection list for assembler style ParsingFrame := TCompilerParsingOptionsFrame(FDialog.FindEditor(TCompilerParsingOptionsFrame)); Assert(Assigned(ParsingFrame)); - ParsingFrame.grpAsmStyle.Visible := (aTargetCPU='i386') or (aTargetCPU='x86_64'); + ParsingFrame.grpAsmStyle.Visible := IsCPUX86(aTargetCPU); end; procedure TCompilerConfigTargetFrame.Setup(ADialog: TAbstractOptionsEditorDialog); diff --git a/ide/frames/compiler_parsing_options.pas b/ide/frames/compiler_parsing_options.pas index 0e4ab67cbb..0c33582d9a 100644 --- a/ide/frames/compiler_parsing_options.pas +++ b/ide/frames/compiler_parsing_options.pas @@ -142,7 +142,7 @@ begin begin cmbSyntaxMode.Text := SyntaxModeToCaption(SyntaxMode); - if (AssemblerStyle in [1,2,3]) then + if (AssemblerStyle in [1,2]) then grpAsmStyle.ItemIndex := AssemblerStyle else grpAsmStyle.ItemIndex := 0;