* Implement -t and -x options

* Fix spurious warning of already specified -t
* If no subtarget file found, error out instead of hint/warn
* Globals needs subtarget for macro substitution
This commit is contained in:
Michael VAN CANNEYT 2022-12-13 10:05:34 +01:00 committed by Michael Van Canneyt
parent 0b7a771ca9
commit 5605cebd46
5 changed files with 384 additions and 307 deletions

View File

@ -256,6 +256,9 @@ interface
outputfilename : string;
outputprefix : pshortstring;
outputsuffix : pshortstring;
{ selected subtarget }
subtarget : string;
{ specified with -FE or -FU }
outputexedir : TPathStr;
outputunitdir : TPathStr;
@ -1002,6 +1005,8 @@ implementation
if (tf_use_8_3 in Source_Info.Flags) or
(tf_use_8_3 in Target_Info.Flags) then
Replace(s,'$FPCTARGET',target_os_string)
else if subtarget<>'' then
Replace(s,'$FPCTARGET',target_full_string+'-'+lower(subtarget))
else
Replace(s,'$FPCTARGET',target_full_string);
Replace(s,'$FPCSUBARCH',lower(cputypestr[init_settings.cputype]));

View File

@ -3629,6 +3629,12 @@ option_unsupported_fpu=11063_F_The selected FPU type "$1" is not supported by th
% Not all instruction sets support all FPU types. For example on ARM, Thumb(-1) supports no FPU/VFP instruction set
option_too_many_exception_modes=11064_E_Only one WebAssembly exception support mode can be specified.
% Only one WebAssembly exception support mode (NOEXCEPTIONS, JSEXCEPTIONS, BFEXCEPTIONS or NATIVEEXCEPTIONS) can be specified.
option_subtarget_is_already_set=11065_W_Subtarget is already set to: $1
% Displayed if more than one \var{-t} option is specified.
option_subtarget_config_not_found=11066_E_Subtarget $1 specified but no corresponding config file $2 found.
% Displayed if more than one \var{-t} option is specified.
option_x_ignored=11067_N_Ignoring compiler executable suffix $1.
% Displayed if more than one \var{-t} option is specified.
%\end{description}
# EndOfTeX
@ -4313,6 +4319,10 @@ Z*2Tzxspectrum_ZX Spectrum
W*2Tembedded_Embedded
W*2Twasi_The WebAssembly System Interface (WASI)
# end of targets section
**1t<x>_Target architecture
**2*_ * Defines FPC_SUBTARGET_<x>
**2*_ * Defines FPC_SUBTARGET as <arg>
**2*_ * Additionally reads config file fpc-<subtarget>.cfg
**1u<x>_Undefines the symbol <x>
**1U_Unit options:
**2Un_Do not check where the unit name matches the file name
@ -4416,6 +4426,7 @@ P*2WT_Specify MPW tool type application (Classic Mac OS)
6*3WQqhdr_Set metadata to QDOS File Header style (default)
6*3WQxtcc_Set metadata to XTcc style
**2WX_Enable executable stack (Linux)
**1x<suff>_Set suffix for compiler executable (fpc command only).
**1X_Executable options:
**2X9_Generate linkerscript for GNU Binutils ld older than version 2.19.1 (Linux)
**2Xa_Generate code which allows to use more than 2 GB static data on 64 bit targets (Linux)

View File

@ -1104,6 +1104,9 @@ const
option_valgrind_heaptrc_mismatch=11062;
option_unsupported_fpu=11063;
option_too_many_exception_modes=11064;
option_subtarget_is_already_set=11065;
option_subtarget_config_not_found=11066;
option_x_ignored=11067;
wpo_cant_find_file=12000;
wpo_begin_processing=12001;
wpo_end_processing=12002;
@ -1157,9 +1160,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 90618;
MsgTxtSize = 91007;
MsgIdxMax : array[1..20] of longint=(
28,109,366,132,100,63,148,38,223,71,
65,20,30,1,1,1,1,1,1,1
68,20,30,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,7 @@ Type
paratarget : tsystem;
paratargetasm : tasm;
paratargetdbg : tdbg;
parasubtarget : string;
LinkTypeSetExplicitly : boolean;
LinkerSetExplicitly : boolean;
Constructor Create;
@ -123,8 +124,10 @@ const
var
option : toption;
read_subfile, { read subtarget config file, set when a cfgfile is found }
read_configfile, { read config file, set when a cfgfile is found }
disable_configfile : boolean;
subcfg,
fpcdir,
ppccfg,
param_file : string; { file to compile specified on the commandline }
@ -1507,7 +1510,7 @@ begin
not(
(opt[1]='-') and
(
((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l','U'])) or
((length(opt)>1) and (opt[2] in ['i','d','v','T','t','u','n','x','X','l','U'])) or
((length(opt)>3) and (opt[2]='F') and (opt[3]='e')) or
((length(opt)>2) and (opt[2]='C') and (opt[3] in ['a','b','f','p'])) or
((length(opt)>3) and (opt[2]='W') and (opt[3] in ['m','p']))
@ -2782,6 +2785,22 @@ begin
if More<>upper(target_info.shortname) then
Message1(option_target_is_already_set,target_info.shortname);
end;
't' :
begin
more:=Upper(More);
if (more='') then
Message1(option_missing_arg,'-t')
else
begin
if (self.parasubtarget<>'') and (More<>upper(self.parasubtarget)) then
Message1(option_subtarget_is_already_set,self.parasubtarget)
else
begin
self.parasubtarget:=more;
end;
end;
end;
'u' :
if is_identifier(more) then
@ -3177,7 +3196,8 @@ begin
inc(j);
end;
end;
'x' :
message1(option_x_ignored,more);
'X' :
begin
j:=1;
@ -3768,6 +3788,7 @@ procedure toption.writequickinfo;
var
s : string;
i : longint;
emptyOK : Boolean;
procedure addinfo(const hs:string);
begin
@ -3778,6 +3799,7 @@ var
end;
begin
emptyOK:=False;
s:='';
i:=0;
while (i<length(quickinfo)) do
@ -3804,6 +3826,11 @@ begin
addinfo(lower(target_info.shortname));
'P' :
AddInfo(target_cpu_string);
'T' :
begin
addinfo(lower(self.parasubtarget));
emptyOK:=True;
end
else
IllegalPara('-i'+QuickInfo);
end;
@ -3820,7 +3847,7 @@ begin
IllegalPara('-i'+QuickInfo);
end;
end;
if s<>'' then
if (s<>'') or EmptyOK then
begin
writeln(s);
stopoptions(0);
@ -4155,6 +4182,8 @@ begin
end;
end;
procedure read_arguments(cmd:TCmdStr);
procedure def_cpu_macros;
@ -4580,6 +4609,16 @@ begin
{ don't remove this, it's also for fpdoc necessary (FK) }
def_system_macro('FPC_HAS_FEATURE_SUPPORT');
if (Option.parasubtarget<>'') then
begin
def_system_macro('FPC_SUBTARGET_'+Option.parasubtarget);
if cs_support_macro in init_settings.moduleswitches then
set_system_macro('FPC_SUBTARGET',Option.parasubtarget)
else
set_system_compvar('FPC_SUBTARGET',Option.parasubtarget);
// So it can be used in macro substitution.
globals.subtarget:=Option.parasubtarget;
end;
{ make cpu makros available when reading the config files the second time }
def_cpu_macros;
@ -4649,6 +4688,14 @@ begin
read_configfile:=check_configfile(ppccfg,ppccfg)
else
read_configfile := false;
if (option.parasubtarget<>'') then
begin
subcfg:='fpc-'+lower(option.parasubtarget)+'.cfg';
read_subfile:=check_configfile(subcfg,subcfg);
// Warn if we didn't find an architecture-specific file
if not read_subfile then
message2(option_subtarget_config_not_found,option.parasubtarget,subcfg);
end;
{ Read commandline and configfile }
param_file:='';
@ -4656,6 +4703,8 @@ begin
{ read configfile }
if read_configfile then
option.interpret_file(ppccfg);
if read_subfile then
option.interpret_file(subcfg);
{ read parameters again to override config file }
if cmd<>'' then