NSPR hardcodes the C compiler to cl on Windows

RESOLVED FIXED in 4.10.7

Status

NSPR
NSPR
P1
normal
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: Away for a while, Assigned: Away for a while)

Tracking

(Blocks: 1 bug)

other
4.10.7
All
Windows 7

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
NSPR seems to use AC_PROG_CC across the board <http://mxr.mozilla.org/mozilla-central/source/nsprpub/configure.in#613> except on Windows <http://mxr.mozilla.org/mozilla-central/source/nsprpub/configure.in#74> where it sets CC to cl no matter what the environment has decided to set for the C compiler.  This causes us to build NSPR with MSVC even when setting CC=clang-cl in the environment.  I can imagine this affects mingw similarly.

Does anyone know why things are set up this way?  Is this intentional?  It seems to me that changing AC_CHECK_PROGS on line 74 to set the result to a variable other than $CC will make AC_PROG_CC check the environment variable properly...
The first things AC_CHECK_PROGS does, after checking for config.cache, is to check if CC is set and use that. This is what that AC_CHECK_PROGS expands to in configure:

    for ac_prog in cl
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  test -n "$CC" && break
done
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → INVALID
(Assignee)

Comment 2

4 years ago
Oh, yes.  My analysis was incorrect, but the symptoms are still real.  :-)
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
(Assignee)

Comment 3

4 years ago
Created attachment 8451185 [details] [diff] [review]
Do not hardcode cl.exe as the NSPR compiler on Windows; r=wtc
(Assignee)

Updated

4 years ago
Assignee: wtc → ehsan
(Assignee)

Updated

4 years ago
Attachment #8451185 - Flags: review?(wtc)
Comment on attachment 8451185 [details] [diff] [review]
Do not hardcode cl.exe as the NSPR compiler on Windows; r=wtc

I sanity checked that this builds fine on Windows without setting CC in the environment.
Attachment #8451185 - Flags: review?(wtc) → review+
http://hg.mozilla.org/projects/nspr/rev/bb86fe1486b3
Status: REOPENED → RESOLVED
Last Resolved: 4 years ago4 years ago
Resolution: --- → FIXED
(Assignee)

Comment 6

4 years ago
Thanks, Ted!  Should I add a NSPR_4_10_7_BETA3 tag to NSPR and merge this and bug 979278 to m-c?
Flags: needinfo?(ted)
(Assignee)

Comment 7

4 years ago
Landed on inbound: https://hg.mozilla.org/integration/mozilla-inbound/rev/51895ae51261
Flags: needinfo?(ted)

Updated

4 years ago
OS: Mac OS X → Windows 7
Priority: -- → P1
Hardware: x86 → All
Target Milestone: --- → 4.10.7

Comment 9

4 years ago
Comment on attachment 8451185 [details] [diff] [review]
Do not hardcode cl.exe as the NSPR compiler on Windows; r=wtc

Review of attachment 8451185 [details] [diff] [review]:
-----------------------------------------------------------------

r=wtc.

::: nsprpub/configure.in
@@ +1919,5 @@
>          AR='lib -NOLOGO -OUT:"$@"'
>          AR_FLAGS=
>          RANLIB='echo not_ranlib'
>          STRIP='echo not_strip'
>          RC=rc.exe

LD, AR, and RC are also hardcoded. I guess "if it ain't broke,
don't fix it"?
Attachment #8451185 - Flags: superreview+
(Assignee)

Comment 10

4 years ago
(In reply to Wan-Teh Chang from comment #9)
> Comment on attachment 8451185 [details] [diff] [review]
> Do not hardcode cl.exe as the NSPR compiler on Windows; r=wtc
> 
> Review of attachment 8451185 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> r=wtc.
> 
> ::: nsprpub/configure.in
> @@ +1919,5 @@
> >          AR='lib -NOLOGO -OUT:"$@"'
> >          AR_FLAGS=
> >          RANLIB='echo not_ranlib'
> >          STRIP='echo not_strip'
> >          RC=rc.exe
> 
> LD, AR, and RC are also hardcoded. I guess "if it ain't broke,
> don't fix it"?

Yes.  :-)
You need to log in before you can comment on or make changes to this bug.