[m-rev.] for review: work towards supporting 64-bit Windows with MSVC

Peter Wang novalazy at gmail.com
Sun Jun 25 16:11:07 AEST 2023


On Sun, 25 Jun 2023 02:12:05 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> 
> For review by anyone.
> (I intend to to commit this one this evening, since I want to continue
> working on it.)
> 
> ----------------------
> 
> Work towards supporting 64-bit Windows with MSVC.
> 
> compiler/globals.m:
>       Extend c_compiler_type to distinguish between versions of MSVC
>       that target x86 and those that target x86_64 (x64).
> 
> compiler/handle_options.m:
>       Update the list of valid C compiler types.
> 
> compiler/compile_target_code.m:
>       Handle versions of MSVC that generate x86_64 code.
> 
> m4/mercury.m4:
>      Distinguish between versions of MSVC that target x86 and those
>      that target x86_64.
> 
> configure.ac:
>      Generate the new values of --c-compiler-type for MSVC.
> 
>      Determine the CPU type to pass to boehm_gc/NT_MAKEFILE.
>      (This will also require an update to boehm_gc/Mmakefile; this change does
>      not do that.)
> 
> Mmake.common.in:
>      Add a new variable for setting the CPU type for boehm_gc/NT_MAKEFILE.
> 
> Julien.
> 

> diff --git a/Mmake.common.in b/Mmake.common.in
> index 848b376..dc162be 100644
> --- a/Mmake.common.in
> +++ b/Mmake.common.in
> @@ -185,6 +185,10 @@ BOEHM_CFLAGS_FOR_THREADS = @BOEHM_CFLAGS_FOR_THREADS@ \
>   	@ENABLE_BOEHM_THREAD_LOCAL_ALLOC@ \
>   	@ENABLE_BOEHM_PARALLEL_MARK@
> 
> +# The CPU type to pass via the "cpu" argument of boehm_gc/NT_MAKEFILE.
> +# (This is only relevant when using MSVC.)
> +BOEHM_WINDOWS_CPU_TYPE = @BOEHM_WINDOWS_CPU_TYPE@
> +

Or BOEHM_MSVC_CPU_TYPE? Doesn't matter.

> @@ -544,8 +549,14 @@ convert_c_compiler_type_with_version(CC_Str, C_CompilerType) :-
>           convert_gcc_version(Major, Minor, Patch, C_CompilerType)
>       else if Tokens = ["clang", Major, Minor, Patch] then
>           convert_clang_version(Major, Minor, Patch, C_CompilerType)
> -    else if Tokens = ["msvc", Version] then
> -        convert_msvc_version(Version, C_CompilerType)
> +    else if Tokens = ["msvc", "x64", Version] then
> +        convert_msvc_x64_version(Version, C_CompilerType)
> +    else if
> +        ( Tokens = ["msvc", Version]
> +        ; Tokens = ["msvc", "x86", Version]
> +        )
> +    then
> +        convert_msvc_x86_version(Version, C_CompilerType)

Put x86 first, same order as the predicates.

> @@ -629,12 +640,19 @@ convert_clang_version(MajorStr, MinorStr, PatchStr, C_CompilerType) :-
>       % The version number is an integer literal (corresponding to the value
>       % of the builtin macro _MSC_VER).
>       %
> -:- pred convert_msvc_version(string::in, c_compiler_type::out) is semidet.
> +:- pred convert_msvc_x86_version(string::in, c_compiler_type::out) is semidet.
> +
> +convert_msvc_x86_version(VersionStr, C_CompilerType) :-
> +    string.to_int(VersionStr, Version),
> +    Version > 0,
> +    C_CompilerType = cc_cl_x86(yes(Version)).
> +
> +:- pred convert_msvc_x64_version(string::in, c_compiler_type::out) is semidet.
> 
> -convert_msvc_version(VersionStr, C_CompilerType) :-
> +convert_msvc_x64_version(VersionStr, C_CompilerType) :-
>       string.to_int(VersionStr, Version),
>       Version > 0,
> -    C_CompilerType = cc_cl(yes(Version)).
> +    C_CompilerType = cc_cl_x64(yes(Version)).
> 
>   convert_csharp_compiler_type("microsoft", csharp_microsoft).
>   convert_csharp_compiler_type("mono", csharp_mono).

> diff --git a/configure.ac b/configure.ac
> index c4d16e7..a01e997 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -183,6 +183,17 @@ esac
> 
>   #-----------------------------------------------------------------------------#
> 
> +# Work out what CPU type we need to pass to boehm_gc/NT_MAKEFILE.
> +
> +case "$mercury_cv_cc_type" in
> +    msvc_64) BOEHM_WINDOWS_CPU_TYPE="x64" ;;

Missing an x.

> +    *) BOEHM_WINDOWS_CPU_TYPE="x86" ;;
> +esac
> +
> +AC_SUBST([BOEHM_WINDOWS_CPU_TYPE])
> +
> +#-----------------------------------------------------------------------------#
> +
>   AC_CANONICAL_HOST
>   FULLARCH="$host"
>   AC_SUBST(FULLARCH)

The rest seems fine.

Peter


More information about the reviews mailing list