Handle LDFLAGS and LD_LIBFLAGS with `mmc --make'.

Estimated hours taken: 1
Branches: main

Handle LDFLAGS and LD_LIBFLAGS with `mmc --make'.

compiler/options.m:
doc/user_guide.texi:
	Add `--ml-flags' as a synonym for `--link-flags'.

	Add `--ld-flags' and `--ld-libflags', which are the
	options corresponding to the LDFLAGS and LD_LIBFLAGS
	Mmake variables.

	Add a comment that the `--output-file' option is
	ignored with `mmc --make'.

compiler/options_file.m:
	Handle LDFLAGS and LD_LIBFLAGS.

	Handle MLLIBS correctly. MLLIBS contains `-l' options
	(which can be handled by mmc), not flags for ml.

	The value of LIBRARIES (which contains Mercury libraries
	to link with) now comes before MLLIBS, because Mercury
	libraries depend on C libraries, but C libraries usually
	don't depend on Mercury libraries.

compiler/compile_target_code.m:
	Pass the value `--ldflags' or `--ld-libflags' to ml.

scripts/Mmake.vars.in:
	Add LDFLAGS and LD_LIBFLAGS to the options file
	passed to the options file passed to `mmc --make'
	on standard input.
This commit is contained in:
Simon Taylor
2002-05-25 13:25:17 +00:00
parent a268c62a47
commit efd28044af
5 changed files with 69 additions and 9 deletions

View File

@@ -903,12 +903,14 @@ link(ErrorStream, LinkTargetType, ModuleName,
;
( { LinkTargetType = shared_library } ->
{ SharedLibOpt = "--make-shared-lib " },
{ LDFlagsOpt = ld_libflags },
globals__io_lookup_string_option(
shared_library_extension, SharedLibExt),
module_name_to_lib_file_name("lib", ModuleName,
SharedLibExt, yes, OutputFileName)
;
{ SharedLibOpt = "" },
{ LDFlagsOpt = ld_flags },
globals__io_lookup_string_option(
executable_file_extension, ExeExt),
module_name_to_file_name(ModuleName, ExeExt,
@@ -925,6 +927,9 @@ link(ErrorStream, LinkTargetType, ModuleName,
globals__io_lookup_accumulating_option(link_flags,
LinkFlagsList),
{ join_string_list(LinkFlagsList, "", "", " ", LinkFlags) },
globals__io_lookup_accumulating_option(LDFlagsOpt,
LDFlagsList),
{ join_string_list(LDFlagsList, "", "", " ", LDFlags) },
globals__io_lookup_accumulating_option(
link_library_directories,
LinkLibraryDirectoriesList),
@@ -934,11 +939,15 @@ link(ErrorStream, LinkTargetType, ModuleName,
LinkLibrariesList),
{ join_string_list(LinkLibrariesList, "-l", "", " ",
LinkLibraries) },
% Note that LDFlags may contain `-l' options
% so it should come after Objects.
{ string__append_list(
["ml --grade ", Grade, " ", SharedLibOpt,
Target_Debug_Opt, TraceOpt, StdLibOpt, LinkFlags,
" -o ", OutputFileName, " ", Objects, " ",
LinkLibraryDirectories, " ", LinkLibraries],
LinkLibraryDirectories,
" -- -o ", OutputFileName, " ", Objects, " ",
LDFlags, " ", LinkLibraries],
LinkCmd) },
invoke_shell_command(ErrorStream, verbose_commands,
LinkCmd, Succeeded),