Closed Bug 1778929 Opened 3 years ago Closed 3 years ago

Firefox build: stdio.h:63:17: error: 'long type-name' is invalid

Categories

(Firefox Build System :: General, defect)

Firefox 102
x86_64
Linux
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: dan76, Unassigned)

Details

Attachments

(8 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0

Steps to reproduce:

./mach configure

Linux 5.18.10 (x86-64)
glibc 2.35
clang 14.0.6

Actual results:

0:09.62 checking for valid C compiler optimization flags... no
0:09.62 configure: error: These compiler flags for C are invalid: -O2
0:09.63 DEBUG: <truncated - see config.log for full output>
0:09.63 DEBUG: configure:4879: checking for _aligned_malloc in malloc.h
0:09.63 DEBUG: configure:4960: checking if app-specific confvars.sh exists
0:09.63 DEBUG: configure:5033: checking for valid C compiler optimization flags
0:09.63 DEBUG: configure:5044: /usr/bin/ccache /usr/bin/clang -std=gnu99 -c -march=native -O3 -pipe -fPIC -ffunction-sections -fdata-sections -fno-math-errno -pthread -O2 -Qunused-arguments -I/usr/xorg/include conftest.c 1>&5
0:09.63 DEBUG: In file included from configure:5038:
0:09.63 DEBUG: /usr/local/include/stdio.h:63:17: error: 'long type-name' is invalid
0:09.63 DEBUG: typedef __off_t off_t;
0:09.63 DEBUG: ^
0:09.63 DEBUG: ./confdefs.h:3:15: note: expanded from macro 'off_t'
0:09.63 DEBUG: #define off_t long
0:09.63 DEBUG: ^
0:09.63 DEBUG: 1 error generated.
0:09.63 DEBUG: configure: failed program was:
0:09.63 DEBUG: #line 5037 "configure"
0:09.63 DEBUG: #include "confdefs.h"
0:09.63 DEBUG: #include <stdio.h>
0:09.63 DEBUG: int main() {
0:09.63 DEBUG: printf("Hello World\n");
0:09.63 DEBUG: ; return 0; }
0:09.63 DEBUG: configure: error: These compiler flags for C are invalid: -O2
0:09.63 ERROR: old-configure failed
*** Fix above errors and then restart with "./mach build"

Expected results:

The test should be passed without errors.

Component: Untriaged → General
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

A possible workaround is:

sed -i 's|off_t, long|off_t, off_t|' build/autoconf/acspecific.m4

At least until it's fixed. Thanks.

Product: Firefox → Firefox Build System

Can you attach the full contents of the config.log file?

Attached file config.log

config.log attached.

Attachment #9285228 - Attachment mime type: text/x-log → text/plain

Can you also attach the standard output from configure?

Attached file configure.txt

(In reply to Mike Hommey [:glandium] from comment #4)

Can you also attach the standard output from configure?

Yes, configure.txt attached.

So, something is going wrong much earlier:

 0:08.90 checking for mode_t... no
 0:08.92 checking for off_t... no
 0:08.94 checking for pid_t... no
 0:08.96 checking for size_t... no
 0:09.08 checking whether 64-bits std::atomic requires -latomic... do not know; assuming no
 0:09.12 checking for dirent.h that defines DIR... no

these should all be yes. Unfortunately, config.log doesn't give much information about it.

Try without setting CPPFLAGS. If that doesn't help for those checks, try adding set -x before AC_TYPE_MODE_T in old-configure.in and see what the output looks like.

(In reply to Mike Hommey [:glandium] from comment #6)

Try without setting CPPFLAGS. If that doesn't help for those checks, try adding set -x before AC_TYPE_MODE_T in old-configure.in and see what the output looks like.

Unsetting CPPFLAGS didn't help. I attached the full configure output with set -x. Here's an extract:

0:07.75 + echo -n 'checking for mode_t... '
0:07.75 checking for mode_t... + echo 'configure:3421: checking for mode_t'
0:07.75 ++ echo '${ac_cv_type_mode_t+set}'
0:07.75 + eval 'test "${ac_cv_type_mode_t+set}" = set'
0:07.75 ++ test '' = set
0:07.75 + cat
0:07.75 + egrep '(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]'
0:07.77 + rm -rf conftest.c
0:07.77 + ac_cv_type_mode_t=no
0:07.77 + rm -f 'conftest*'
0:07.77 + echo no
0:07.77 no

It's using the cached version of the check result, can you try again after removing config.cache?

(In reply to Mike Hommey [:glandium] from comment #8)

It's using the cached version of the check result, can you try again after removing config.cache?

Sorry about that. Attached the correct one.

Err, actually I misread the previous one, they both are not using the cached version, but there's still not enough to debug. You'll have to debug this manually, unfortunately:
Create a conftest.c file with the following contents:

#line 3426 "configure"
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif

Then run /usr/bin/ccache /usr/bin/clang -std=gnu99 -E conftest.c, check if mode_t appears in the output, and if it doesn't, figure out why.

Attached file conftest.txt

Ok, I attached the conftest.c output and it shows mode_t

typedef unsigned int __mode_t;
typedef __mode_t mode_t;

Let's try something else. Can you apply the following patch, run ./mach configure, then attach the output as well as the foo file that it creates?

--- a/old-configure.in
+++ b/old-configure.in
@@ -620,6 +620,31 @@ if test -z "$SKIP_COMPILER_CHECKS"; then
 dnl Checks for typedefs, structures, and compiler characteristics.
 dnl ========================================================
 AC_C_CONST
+set -x
+echo $ac_n "checking for mode_t""... $ac_c" 1>&6
+echo "configure:3420: checking for mode_t" >&5
+  cat > conftest.$ac_ext <<EOF
+#line 3425 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+eval echo "$ac_cpp conftest.$ac_ext"
+if (eval "$ac_cpp conftest.$ac_ext") | tee foo |
+  egrep "(^|[[^a-zA-Z_0-9]])mode_t[[^a-zA-Z_0-9]]" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_type_mode_t=yes
+else
+  rm -rf conftest*
+  ac_cv_type_mode_t=no
+fi
+rm -f conftest*
+echo "$ac_t""$ac_cv_type_mode_t" 1>&6
+
+exit
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T

Ok, here's the output with the old-configure.in patched.

Attached file foo

Here is the "foo" file.

Attachment #9285414 - Attachment mime type: application/octet-stream → text/plain

Can you try again after replacing
egrep "(^|[[^a-zA-Z_0-9]])mode_t[[^a-zA-Z_0-9]]" >/dev/null 2>&1; then
with
egrep "(^|[[^a-zA-Z_0-9]])mode_t[[^a-zA-Z_0-9]]"; then
and attach the output from ./mach configure (no need for foo this time)

Ok, ./mach configure output with patch without /dev/null attached.

I think you found the issue! The problem was with egrep.

I was using version (e)grep 3.7, installed last year. For some unknown reason it was causing this bug. I reinstalled it and now it works. Amazing!

Thank you!

Ps: so I'm closing this, since the issue was with grep and not with Firefox.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: