[m-rev.] for review: autoconfigure which version of .NET std lib to use
Peter Ross
peter.ross at miscrit.be
Sat Mar 2 00:57:59 AEDT 2002
On Fri, Mar 01, 2002 at 11:26:41PM +1100, Fergus Henderson wrote:
> Please post another diff when you've addressed these comments.
>
Estimated hours taken: 2.5
Branches: main
Configure the version of the .NET std library that we are using instead
of hard-coding it in the compiler.
aclocal.m4:
Find the version number of the mscorlib assembly and record it in
MS_DOTNET_LIBRARY_VERSION.
compiler/options.m:
compiler/mlds_to_il.m:
doc/user_guide.texi:
Add the option --dotnet-library-version, and use it to determine
which version of the .NET standard libraries to refer too.
compiler/mlds_to_il.m:
We no longer need to hard-code the hash for the mscorlib.dll.
scripts/mmc.in:
Use the autoconfigured MS_DOTNET_LIBRARY_VERSION to set the
--dotnet-library-version. This is commented out for the moment
until this change bootstraps.
diff -u aclocal.m4 aclocal.m4
--- aclocal.m4
+++ aclocal.m4
@@ -98,6 +98,22 @@
AC_MSG_RESULT($mercury_cv_microsoft_visual_cpp)
MS_CL=`basename "$MS_CL"`
+AC_PATH_PROG(MS_CSC, csc)
+AC_MSG_CHECKING(for Microsoft.NET Visual C sharp)
+AC_CACHE_VAL(mercury_cv_microsoft_visual_csharp, [
+if test "$MS_CSC" != ""; then
+ changequote(<<,>>)
+ MS_VISUALCSHARP_DIR=`expr "$MS_CSC" : '\(.*\)[/\\]*[bB]in[/\\]*csc`
+ changequote([,])
+ mercury_cv_microsoft_visual_csharp="yes"
+else
+ MS_VISUALCSHARP_DIR=""
+ mercury_cv_microsoft_visual_csharp="no"
+fi
+])
+AC_MSG_RESULT($mercury_cv_microsoft_visual_csharp)
+MS_CSC=`basename "$MS_CSC"`
+
# We default to the Beta 2 version of the library
mercury_cv_microsoft_dotnet_library_version=1.0.2411.0
if test $mercury_cv_microsoft_dotnet = "yes"; then
@@ -117,16 +133,19 @@
}
EOF
if
- echo csc conftest.cs >&AC_FD_CC 2>&1 && \
- csc conftest.cs >&AC_FD_CC 2>&1
+ echo $MS_CSC conftest.cs >&AC_FD_CC 2>&1 && \
+ $MS_CSC conftest.cs >&AC_FD_CC 2>&1 && \
+ ./conftest > conftest.out 2>&1
then
- mercury_cv_microsoft_dotnet_library_version=`./conftest`
+ mercury_cv_microsoft_dotnet_library_version=`cat conftest.out`
AC_MSG_RESULT($mercury_cv_microsoft_dotnet_library_version)
rm -f conftest*
else
rm -f conftest*
AC_MSG_ERROR(unable to determine version)
- exit 1
+ if test $enable_dotnet_grades = "yes"; then
+ exit 1
+ fi
fi
fi
MS_DOTNET_LIBRARY_VERSION=$mercury_cv_microsoft_dotnet_library_version
@@ -134,6 +153,7 @@
AC_SUBST(ILASM)
AC_SUBST(GACUTIL)
AC_SUBST(MS_CL)
+AC_SUBST(MS_CSC)
AC_SUBST(MS_DOTNET_SDK_DIR)
AC_SUBST(MS_DOTNET_LIBRARY_VERSION)
AC_SUBST(MS_VISUALCPP_DIR)
diff -u compiler/mlds_to_il.m compiler/mlds_to_il.m
--- compiler/mlds_to_il.m
+++ compiler/mlds_to_il.m
@@ -73,7 +73,7 @@
%
% This is where all the action is for the IL backend.
%
-:- pred generate_il(mlds, list(ilasm:decl), set(foreign_language),
+:- pred generate_il(mlds, list(ilasm__decl), set(foreign_language),
io__state, io__state).
:- mode generate_il(in, out, out, di, uo) is det.
@@ -218,18 +218,18 @@
{ MaybeVersion = yes(Version) }
;
{ MaybeVersion = no },
- io__stderr_stream(StdErr),
- io__write_string(StdErr, "error: Invalid version string `"),
- io__write_string(StdErr, VersionStr),
- io__write_string(StdErr, "' passed " ),
- io__write_string(StdErr, "to --dotnet-library-version.\n"),
+ write_error_pieces_maybe_with_context(no, 0, [
+ words("Error: invalid version string"),
+ words("`" ++ VersionStr ++ "'"),
+ words("passed to `--dotnet-library-version'.")
+ ]),
io__set_exit_status(1)
).
%-----------------------------------------------------------------------------%
:- pred generate_il(mlds, assembly_decl,
- list(ilasm:decl), set(foreign_language),
+ list(ilasm__decl), set(foreign_language),
io__state, io__state).
:- mode generate_il(in, in, out, out, di, uo) is det.
@@ -3995,8 +3995,7 @@
AsmDecls)]
)
; SeparateAssemblies = yes,
- Decl = [extern_assembly(ModuleName,
- AsmDecls)]
+ Decl = [extern_assembly(ModuleName, AsmDecls)]
)
)
),
@@ -4011,15 +4010,7 @@
])
]),
extern_assembly("mscorlib",
- dotnet_system_assembly_decls(Version) ++
- [hash([
- int8(0xb0), int8(0x73), int8(0xf2), int8(0x4c),
- int8(0x14), int8(0x39), int8(0x0a), int8(0x35),
- int8(0x25), int8(0xea), int8(0x45), int8(0x0f),
- int8(0x60), int8(0x58), int8(0xc3), int8(0x84),
- int8(0xe0), int8(0x3b), int8(0xe0), int8(0x95)
- ])
- ]) | Decls].
+ dotnet_system_assembly_decls(Version)) | Decls].
:- func dotnet_system_assembly_decls(assembly_decl) = list(assembly_decl).
diff -u compiler/options.m compiler/options.m
--- compiler/options.m
+++ compiler/options.m
@@ -3081,8 +3081,8 @@
"\tSpecify an extension for Java object (bytecode) files",
"\tBy default this is `.class'.",
- "--dotnet-library-version",
- "\tThe version number for the standard libraries distributed",
+ "--dotnet-library-version <version-number>",
+ "\tThe version number for the mscorlib assembly distributed",
"\twith the Microsoft .NET SDK."
]).
diff -u doc/user_guide.texi doc/user_guide.texi
--- doc/user_guide.texi
+++ doc/user_guide.texi
@@ -5629,9 +5629,9 @@
is @samp{.class}.
@sp 1
- at item --dotnet-library-version @var{extension}
+ at item --dotnet-library-version @var{version-number}
@findex --dotnet-library-version
-The version number for the standard libraries distributed with the
+The version number for the mscorlib assembly distributed with the
Microsoft .NET SDK.
@end table
diff -u scripts/mmc.in scripts/mmc.in
--- scripts/mmc.in
+++ scripts/mmc.in
@@ -34,7 +34,7 @@
NUM_REAL_R_TEMPS=@NUM_REAL_R_TEMPS@
HAVE_DELAY_SLOT=@HAVE_DELAY_SLOT@
HAVE_BOXED_FLOATS=@HAVE_BOXED_FLOATS@
-DOTNET_LIBRARY_VERSION=@MS_DOTNET_LIBRARY_VERSION@
+MS_DOTNET_LIBRARY_VERSION=@MS_DOTNET_LIBRARY_VERSION@
DEFAULT_OPT_LEVEL=${MERCURY_DEFAULT_OPT_LEVEL="-O2"}
# The default optimization level should be after
@@ -42,7 +42,7 @@
# XXX when the compiler has bootstrapped we need to add the following to
# the mmc command line
-# --dotnet-library-version "$DOTNET_LIBRARY_VERSION"
+# --dotnet-library-version "$MS_DOTNET_LIBRARY_VERSION"
case $# in
0) exec $MC \
$MERC_ALL_MC_C_INCL_DIRS \
The full diff again
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.7
diff -u -r1.7 aclocal.m4
--- aclocal.m4 11 Feb 2002 12:11:31 -0000 1.7
+++ aclocal.m4 1 Mar 2002 13:53:45 -0000
@@ -98,10 +98,64 @@
AC_MSG_RESULT($mercury_cv_microsoft_visual_cpp)
MS_CL=`basename "$MS_CL"`
+AC_PATH_PROG(MS_CSC, csc)
+AC_MSG_CHECKING(for Microsoft.NET Visual C sharp)
+AC_CACHE_VAL(mercury_cv_microsoft_visual_csharp, [
+if test "$MS_CSC" != ""; then
+ changequote(<<,>>)
+ MS_VISUALCSHARP_DIR=`expr "$MS_CSC" : '\(.*\)[/\\]*[bB]in[/\\]*csc`
+ changequote([,])
+ mercury_cv_microsoft_visual_csharp="yes"
+else
+ MS_VISUALCSHARP_DIR=""
+ mercury_cv_microsoft_visual_csharp="no"
+fi
+])
+AC_MSG_RESULT($mercury_cv_microsoft_visual_csharp)
+MS_CSC=`basename "$MS_CSC"`
+
+# We default to the Beta 2 version of the library
+mercury_cv_microsoft_dotnet_library_version=1.0.2411.0
+if test $mercury_cv_microsoft_dotnet = "yes"; then
+ AC_MSG_CHECKING(determining version of .NET libraries)
+ cat > conftest.cs << EOF
+ using System;
+ using System.Reflection;
+ public class version {
+ public static void Main()
+ {
+ Assembly asm = Assembly.Load("mscorlib");
+ AssemblyName name = asm.GetName();
+ Version version = name.Version;
+ Console.Write(version);
+ Console.Write("\n");
+ }
+ }
+EOF
+ if
+ echo $MS_CSC conftest.cs >&AC_FD_CC 2>&1 && \
+ $MS_CSC conftest.cs >&AC_FD_CC 2>&1 && \
+ ./conftest > conftest.out 2>&1
+ then
+ mercury_cv_microsoft_dotnet_library_version=`cat conftest.out`
+ AC_MSG_RESULT($mercury_cv_microsoft_dotnet_library_version)
+ rm -f conftest*
+ else
+ rm -f conftest*
+ AC_MSG_ERROR(unable to determine version)
+ if test $enable_dotnet_grades = "yes"; then
+ exit 1
+ fi
+ fi
+fi
+MS_DOTNET_LIBRARY_VERSION=$mercury_cv_microsoft_dotnet_library_version
+
AC_SUBST(ILASM)
AC_SUBST(GACUTIL)
AC_SUBST(MS_CL)
+AC_SUBST(MS_CSC)
AC_SUBST(MS_DOTNET_SDK_DIR)
+AC_SUBST(MS_DOTNET_LIBRARY_VERSION)
AC_SUBST(MS_VISUALCPP_DIR)
])
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.105
diff -u -r1.105 mlds_to_il.m
--- compiler/mlds_to_il.m 27 Feb 2002 16:21:30 -0000 1.105
+++ compiler/mlds_to_il.m 1 Mar 2002 13:53:47 -0000
@@ -73,7 +73,7 @@
%
% This is where all the action is for the IL backend.
%
-:- pred generate_il(mlds, list(ilasm:decl), set(foreign_language),
+:- pred generate_il(mlds, list(ilasm__decl), set(foreign_language),
io__state, io__state).
:- mode generate_il(in, out, out, di, uo) is det.
@@ -192,7 +192,48 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-generate_il(MLDS, ILAsm, ForeignLangs, IO0, IO) :-
+generate_il(MLDS, ILAsm, ForeignLangs) -->
+ maybe_get_dotnet_library_version(MaybeVersion),
+ ( { MaybeVersion = yes(Version) },
+ generate_il(MLDS, Version, ILAsm, ForeignLangs)
+ ; { MaybeVersion = no },
+ { ILAsm = [] },
+ { ForeignLangs = set__init }
+ ).
+
+:- pred maybe_get_dotnet_library_version(maybe(assembly_decl)::out,
+ io::di, io::uo) is det.
+
+maybe_get_dotnet_library_version(MaybeVersion) -->
+ io_lookup_string_option(dotnet_library_version, VersionStr),
+ { IsSep = (pred(('.')::in) is semidet) },
+ (
+ { string__words(IsSep, VersionStr) = [Mj, Mn, Bu, Rv] },
+ { string__to_int(Mj, Major) },
+ { string__to_int(Mn, Minor) },
+ { string__to_int(Bu, Build) },
+ { string__to_int(Rv, Revision) }
+ ->
+ { Version = version(Major, Minor, Build, Revision) },
+ { MaybeVersion = yes(Version) }
+ ;
+ { MaybeVersion = no },
+ write_error_pieces_maybe_with_context(no, 0, [
+ words("Error: invalid version string"),
+ words("`" ++ VersionStr ++ "'"),
+ words("passed to `--dotnet-library-version'.")
+ ]),
+ io__set_exit_status(1)
+ ).
+
+%-----------------------------------------------------------------------------%
+
+:- pred generate_il(mlds, assembly_decl,
+ list(ilasm__decl), set(foreign_language),
+ io__state, io__state).
+:- mode generate_il(in, in, out, out, di, uo) is det.
+
+generate_il(MLDS, Version, ILAsm, ForeignLangs, IO0, IO) :-
mlds(MercuryModuleName, _ForeignCode, Imports, Defns) =
transform_mlds(MLDS),
@@ -261,8 +302,8 @@
ForeignCodeAssemblerRefs),
AssemblerRefs = list__append(ForeignCodeAssemblerRefs, Imports)
),
- generate_extern_assembly(AssemblyName, SignAssembly, SeparateAssemblies,
- AssemblerRefs, ExternAssemblies),
+ generate_extern_assembly(AssemblyName, Version, SignAssembly,
+ SeparateAssemblies, AssemblerRefs, ExternAssemblies),
Namespace = [namespace(NamespaceName, ILDecls)],
ILAsm = list__condense([ThisAssembly, ExternAssemblies, Namespace]).
@@ -3914,10 +3955,10 @@
%-----------------------------------------------------------------------------
% Generate extern decls for any assembly we reference.
-:- pred mlds_to_il__generate_extern_assembly(string::in, bool::in, bool::in,
- mlds__imports::in, list(decl)::out) is det.
+:- pred mlds_to_il__generate_extern_assembly(string::in, assembly_decl::in,
+ bool::in, bool::in, mlds__imports::in, list(decl)::out) is det.
-mlds_to_il__generate_extern_assembly(CurrentAssembly, SignAssembly,
+mlds_to_il__generate_extern_assembly(CurrentAssembly, Version, SignAssembly,
SeparateAssemblies, Imports, AllDecls) :-
Gen = (pred(Import::in, Decl::out) is semidet :-
( Import = mercury_import(ImportName),
@@ -3933,7 +3974,7 @@
prog_out__sym_name_to_string(PackageName,
ForeignPackageStr),
( string__prefix(ForeignPackageStr, "System") ->
- AsmDecls = dotnet_system_assembly_decls
+ AsmDecls = dotnet_system_assembly_decls(Version)
;
AsmDecls = []
)
@@ -3954,8 +3995,7 @@
AsmDecls)]
)
; SeparateAssemblies = yes,
- Decl = [extern_assembly(ModuleName,
- AsmDecls)]
+ Decl = [extern_assembly(ModuleName, AsmDecls)]
)
)
),
@@ -3970,21 +4010,13 @@
])
]),
extern_assembly("mscorlib",
- dotnet_system_assembly_decls ++
- [hash([
- int8(0xb0), int8(0x73), int8(0xf2), int8(0x4c),
- int8(0x14), int8(0x39), int8(0x0a), int8(0x35),
- int8(0x25), int8(0xea), int8(0x45), int8(0x0f),
- int8(0x60), int8(0x58), int8(0xc3), int8(0x84),
- int8(0xe0), int8(0x3b), int8(0xe0), int8(0x95)
- ])
- ]) | Decls].
+ dotnet_system_assembly_decls(Version)) | Decls].
-:- func dotnet_system_assembly_decls = list(assembly_decl).
+:- func dotnet_system_assembly_decls(assembly_decl) = list(assembly_decl).
-dotnet_system_assembly_decls
+dotnet_system_assembly_decls(Version)
= [
- version(1, 0, 2411, 0),
+ Version,
public_key_token([
int8(0xb7), int8(0x7a), int8(0x5c), int8(0x56),
int8(0x19), int8(0x34), int8(0xE0), int8(0x89)
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.357
diff -u -r1.357 options.m
--- compiler/options.m 23 Feb 2002 07:30:46 -0000 1.357
+++ compiler/options.m 1 Mar 2002 13:53:49 -0000
@@ -471,7 +471,9 @@
; java_flags
; java_classpath
; java_object_file_extension
-
+
+ % IL
+ ; dotnet_library_version
% Link options
; output_file_name
@@ -909,6 +911,7 @@
option_defaults_2(target_code_compilation_option, [
% Target code compilation options
target_debug - bool(no),
+
% C
% the `mmc' script will override the
% following default with a value
@@ -937,7 +940,12 @@
java_compiler - string("javac"),
java_flags - accumulating([]),
java_classpath - accumulating([]),
- java_object_file_extension - string(".class")
+ java_object_file_extension - string(".class"),
+
+% IL
+ % We default to the version of the library that came
+ % with Beta2.
+ dotnet_library_version - string("1.0.2411.0")
]).
option_defaults_2(link_option, [
% Link Options
@@ -1464,6 +1472,8 @@
long_option("java-classpath", java_classpath).
long_option("java-object-file-extension", java_object_file_extension).
+long_option("dotnet-library-version", dotnet_library_version).
+
% link options
long_option("output-file", output_file_name).
long_option("link-flags", link_flags).
@@ -3069,7 +3079,11 @@
"--java-object-file-extension",
"\tSpecify an extension for Java object (bytecode) files",
- "\tBy default this is `.class'."
+ "\tBy default this is `.class'.",
+
+ "--dotnet-library-version <version-number>",
+ "\tThe version number for the mscorlib assembly distributed",
+ "\twith the Microsoft .NET SDK."
]).
:- pred options_help_link(io__state::di, io__state::uo) is det.
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.297
diff -u -r1.297 user_guide.texi
--- doc/user_guide.texi 27 Feb 2002 17:41:11 -0000 1.297
+++ doc/user_guide.texi 1 Mar 2002 13:53:54 -0000
@@ -5628,6 +5628,12 @@
Specify an extension for Java object (bytecode) files. By default this
is @samp{.class}.
+ at sp 1
+ at item --dotnet-library-version @var{version-number}
+ at findex --dotnet-library-version
+The version number for the mscorlib assembly distributed with the
+Microsoft .NET SDK.
+
@end table
@node Link options
Index: scripts/mmc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmc.in,v
retrieving revision 1.18
diff -u -r1.18 mmc.in
--- scripts/mmc.in 19 Nov 2001 07:25:08 -0000 1.18
+++ scripts/mmc.in 1 Mar 2002 13:53:54 -0000
@@ -34,11 +34,15 @@
NUM_REAL_R_TEMPS=@NUM_REAL_R_TEMPS@
HAVE_DELAY_SLOT=@HAVE_DELAY_SLOT@
HAVE_BOXED_FLOATS=@HAVE_BOXED_FLOATS@
+MS_DOTNET_LIBRARY_VERSION=@MS_DOTNET_LIBRARY_VERSION@
DEFAULT_OPT_LEVEL=${MERCURY_DEFAULT_OPT_LEVEL="-O2"}
# The default optimization level should be after
# all the options that describe the machine configuration.
+# XXX when the compiler has bootstrapped we need to add the following to
+# the mmc command line
+# --dotnet-library-version "$MS_DOTNET_LIBRARY_VERSION"
case $# in
0) exec $MC \
$MERC_ALL_MC_C_INCL_DIRS \
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list