additional opts should be on the left of other CFLAGS,

this fixes linking to third party libraries issue on some operating systems
including Ubuntu and Debian, probably older gcc 11 is to blame.
Did not notice this problem on Gentoo, at least with gcc 13.
This commit is contained in:
Norayr Chilingarian 2023-10-05 16:54:37 +04:00
parent bd35c73c1f
commit b8d08c007a

View file

@ -44,12 +44,13 @@ BEGIN
END execute; END execute;
PROCEDURE InitialiseCompilerCommand(VAR s: ARRAY OF CHAR); PROCEDURE InitialiseCompilerCommand(VAR s: ARRAY OF CHAR; additionalopts: ARRAY OF CHAR);
BEGIN BEGIN
COPY(Configuration.compile, s); COPY(Configuration.compile, s);
Strings.Append(' -I "', s); Strings.Append(' -I "', s);
Strings.Append(OPM.ResourceDir, s); Strings.Append(OPM.ResourceDir, s);
Strings.Append('/include" ', s); Strings.Append('/include" ', s);
Strings.Append(additionalopts, s);
Platform.GetEnv("CFLAGS", CFLAGS); Platform.GetEnv("CFLAGS", CFLAGS);
Strings.Append (CFLAGS, s); Strings.Append (CFLAGS, s);
Strings.Append (" ", s); Strings.Append (" ", s);
@ -60,7 +61,7 @@ PROCEDURE Assemble*(moduleName: ARRAY OF CHAR);
VAR VAR
cmd: CommandString; cmd: CommandString;
BEGIN BEGIN
InitialiseCompilerCommand(cmd); InitialiseCompilerCommand(cmd, "");
Strings.Append("-c ", cmd); Strings.Append("-c ", cmd);
Strings.Append(moduleName, cmd); Strings.Append(moduleName, cmd);
Strings.Append(".c", cmd); Strings.Append(".c", cmd);
@ -72,10 +73,9 @@ PROCEDURE LinkMain*(VAR moduleName: ARRAY OF CHAR; statically: BOOLEAN; addition
VAR VAR
cmd: CommandString; cmd: CommandString;
BEGIN BEGIN
InitialiseCompilerCommand(cmd); InitialiseCompilerCommand(cmd, additionalopts);
Strings.Append(moduleName, cmd); Strings.Append(moduleName, cmd);
Strings.Append(".c ", cmd); Strings.Append(".c ", cmd);
Strings.Append(additionalopts, cmd);
IF statically THEN IF statically THEN
IF Configuration.os = "darwin" THEN IF Configuration.os = "darwin" THEN
Strings.Append(OPM.InstallDir, cmd); Strings.Append(OPM.InstallDir, cmd);