[m-rev.] for review: generate strongly named assemblies

Tyson Dowd trd at cs.mu.OZ.AU
Sun Aug 12 20:44:16 AEST 2001


On 10-Aug-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> Hi,
> 
> 
> ===================================================================
> 
> 
> Estimated hours taken: 8
> Branches: main
> 
> Optionally generate strongly named assemblies on the IL backend.
> 
> We use the fact that you are allowed use the same key pair to sign more
> then one assembly.  The key pair we use is the one used to sign the
> mercury std library.  This allows us to place the correct public key
> token in the `.assembly extern' reference.
> 
> README.DotNet:
>     Document how to generate a strongly named assembly.
> 
> compiler/mlds_to_csharp.m:
> compiler/mlds_to_mcpp.m:
>     If --sign-assembly is enabled output a custom attribute which
>     references the strong name key file `mercury.sn'.
> 
> compiler/mlds_to_il.m:
>     If --sign-assembly is enabled add the correct decls to all the
>     `.assembly extern' declarations.
>     
> compiler/modules.m:
>     If --sign-assembly we need to generate a dependency between the IL
>     file and the strong name key file `mercury.sn', also add the
>     variable ILASM_KEYFLAG-<module> so that we add the option to sign
>     the assembly with the key file `mercury.sn'.
>     
> compiler/options.m:
>     Add --sign-assembly.
> 
> library/Mmakefile:
>     Install the library strong name file as `mercury.sn' in the dll
>     install directory.
> 
> scripts/Mmake.rules:
>     Add a rule to copy mercury.sn into the local subdirectory.  This is
>     needed so that cpp and csharp modules can reference this file.
>     
> scripts/Mmake.vars.in:
>     Add the ILASM_KEYFLAG variables.
> 
> 

> Index: README.DotNet
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/README.DotNet,v
> retrieving revision 1.6
> diff -u -r1.6 README.DotNet
> --- README.DotNet	9 Aug 2001 16:30:24 -0000	1.6
> +++ README.DotNet	10 Aug 2001 12:14:43 -0000
> @@ -138,6 +138,11 @@
>  For example, module.m will be placed into the assembly `module', while
>  module.sub.m will also be placed into the assembly `module'.
>  
> +To create a strongly named assemblies in Mercury you need to pass the
> +--sign-assembly flag to the Mercury compiler.  Note that this flag needs
> +to be also passed when generating the dependencies for the module being
> +compiled.
> +

You should document that we use the installed mercury.sn strong name,
and this is the only one that will work currently.

Also, not that this is probably temporary (the limitation to mercury.sn
but also the exact option to do this with).

>  -----------------------------------------------------------------------------
>  
>  RESOURCES
> Index: compiler/mlds_to_csharp.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_csharp.m,v
> retrieving revision 1.13
> diff -u -r1.13 mlds_to_csharp.m
> --- compiler/mlds_to_csharp.m	2 Aug 2001 19:50:36 -0000	1.13
> +++ compiler/mlds_to_csharp.m	10 Aug 2001 12:14:43 -0000
> @@ -106,6 +106,13 @@
>  	generate_foreign_header_code(mercury_module_name_to_mlds(ModuleName),
>  		ForeignCode),
>  
> +	globals__io_lookup_bool_option(sign_assembly, SignAssembly),
> +	( { SignAssembly = yes },
> +		io__write_string("[assembly:System.Reflection.AssemblyKeyFileAttribute(\"mercury.sn\")]\n")
> +	; { SignAssembly = no },
> +		[]
> +	),
> +
>  	{ Namespace0 = get_class_namespace(ClassName) },
>  	{ list__reverse(Namespace0) = [Head | Tail] ->
>  		Namespace = list__reverse([Head ++ "__csharp_code" | Tail])

This is interesting.  We could adopt almost exactly the same approach to
allow people to sign assemblies in Mercury, using (an extension of) the
attribute pragma (in the dotnet-foreign branch).

But they was you are doing it at the moment is OK.

> Index: compiler/options.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
> retrieving revision 1.332
> diff -u -r1.332 options.m
> --- compiler/options.m	2 Aug 2001 19:50:37 -0000	1.332
> +++ compiler/options.m	10 Aug 2001 12:14:49 -0000

> @@ -1938,7 +1941,12 @@
>  		"\tto `<module>.base_schema' and for Aditi derived",
>  		"\trelations to `<module>.derived_schema'.",
>  		"\tA schema string is a representation of the types",
> -		"\tof a relation."
> +		"\tof a relation.",
> +
> +		"--sign-assembly",
> +		"\tSign the current assembly with the mercury strong name.",
> +		"\tTo use assemblies created with this command all the mercury",
> +		"\tmodules must be compiled with this option enabled."
>  	]).
>  

s/mercury/Mercury.

This option is .NET specific, and should be put in a .NET section of the
--help output (or at least marked as .NET specific).

It should also be marked as likely to change in future - in the long run
we probably won't install the Mercury keypair.

Otherwise this change is fine, thanks.

Tyson.
--------------------------------------------------------------------------
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