Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build Julia with Clang on Linux #44352

Closed
giordano opened this issue Feb 26, 2022 · 6 comments · Fixed by #44353
Closed

Can't build Julia with Clang on Linux #44352

giordano opened this issue Feb 26, 2022 · 6 comments · Fixed by #44353
Labels
building Build system, or building Julia or its dependencies

Comments

@giordano
Copy link
Contributor

giordano commented Feb 26, 2022

% make CC=clang CXX=clang++ 
    CC src/jltypes.o
/home/mose/repo/julia/src/jltypes.c:2002:13: error: initializer element is not a compile-time constant
            jl_typename_type,
            ^~~~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2027:43: error: initializer element is not a compile-time constant
    jl_typename_type->types = jl_svec(13, jl_symbol_type, jl_any_type /*jl_module_type*/,
                                          ^~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2047:44: error: initializer element is not a compile-time constant
    jl_methtable_type->types = jl_svec(12, jl_symbol_type, jl_any_type, jl_any_type,
                                           ^~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2092:52: error: initializer element is not a compile-time constant
                                        jl_svec(2, jl_any_type, jl_any_type),
                                                   ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2097:47: error: initializer element is not a compile-time constant
                                   jl_svec(3, jl_symbol_type, jl_any_type, jl_any_type),
                                              ^~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2102:51: error: initializer element is not a compile-time constant
                                       jl_svec(2, jl_tvar_type, jl_any_type),
                                                  ^~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2107:56: error: initializer element is not a compile-time constant
                                            jl_svec(2, jl_any_type, jl_any_type),
                                                       ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2110:45: error: initializer element is not a compile-time constant
    jl_svec_t *anytuple_params = jl_svec(1, jl_wrap_vararg((jl_value_t*)jl_any_type, (jl_value_t*)NULL));
                                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2122:61: error: initializer element is not a compile-time constant
    ((jl_datatype_t*)jl_type_type)->parameters = jl_svec(1, tttvar);
                                                            ^~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2161:52: error: initializer element is not a compile-time constant
                                        jl_svec(2, jl_long_type, jl_any_type),
                                                   ^~~~~~~~~~~~
./julia.h:1509:26: note: expanded from macro 'jl_long_type'
#define jl_long_type     jl_int64_type
                         ^~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2195:29: error: initializer element is not a compile-time constant
                            jl_any_type,
                            ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2218:29: error: initializer element is not a compile-time constant
                            jl_any_type, // Union{TypeMapEntry, Nothing}
                            ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2270:36: error: initializer element is not a compile-time constant
                        jl_svec(2, jl_symbol_type, jl_array_any_type),
                                   ^~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2283:36: error: initializer element is not a compile-time constant
                        jl_svec(2, jl_long_type, jl_type_union(symornothing, 2)),
                                   ^~~~~~~~~~~~
./julia.h:1509:26: note: expanded from macro 'jl_long_type'
#define jl_long_type     jl_int64_type
                         ^~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2289:36: error: initializer element is not a compile-time constant
                        jl_svec(5, jl_module_type, jl_any_type, jl_symbol_type, jl_long_type, jl_long_type),
                                   ^~~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2295:36: error: initializer element is not a compile-time constant
                        jl_svec(1, jl_long_type),
                                   ^~~~~~~~~~~~
./julia.h:1509:26: note: expanded from macro 'jl_long_type'
#define jl_long_type     jl_int64_type
                         ^~~~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2301:36: error: initializer element is not a compile-time constant
                        jl_svec(2, jl_any_type, jl_long_type),
                                   ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2307:36: error: initializer element is not a compile-time constant
                        jl_svec(1, jl_any_type),
                                   ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
/home/mose/repo/julia/src/jltypes.c:2313:36: error: initializer element is not a compile-time constant
                        jl_svec(2, jl_any_type, jl_any_type),
                                   ^~~~~~~~~~~
./julia_internal.h:438:41: note: expanded from macro 'jl_svec'
                n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *),        \
                                        ^~~~~~~~~~~
/usr/include/sys/cdefs.h:459:53: note: expanded from macro '_Static_assert'
      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
                                                    ^~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: *** [Makefile:217: jltypes.o] Error 1
make: *** [Makefile:76: julia-src-release] Error 2
% clang --version
clang version 13.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

The build is successful if removing the assertions at

julia/src/julia_internal.h

Lines 428 to 430 in a2e4226

static_assert( \
n == sizeof((char *[]){ __VA_ARGS__ })/sizeof(char *), \
"Number of passed arguments does not match expected number"); \

julia/src/julia_internal.h

Lines 437 to 439 in a2e4226

static_assert( \
n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *), \
"Number of passed arguments does not match expected number"); \

julia/src/julia_internal.h

Lines 445 to 447 in a2e4226

static_assert( \
n == sizeof((void *[]){ __VA_ARGS__ })/sizeof(void *), \
"Number of passed arguments does not match expected number"); \

but probably one would like to compile Julia without having to edit the source code.

@giordano giordano added the building Build system, or building Julia or its dependencies label Feb 26, 2022
@simeonschaub
Copy link
Member

Hmm, aren't all of those inside an ​#​ifdef​ __GNUC__?

@giordano
Copy link
Contributor Author

% clang -dM -E - < /dev/null | grep __GNUC__ 
#define __GNUC__ 4

@simeonschaub
Copy link
Member

simeonschaub commented Feb 26, 2022

@giordano
Copy link
Contributor Author

giordano commented Feb 26, 2022

If the idea was to check for GCC, https://stackoverflow.com/a/28166605/2442087 basically suggests to check (defined(__GNUC__) && !defined(__clang__)). This would be kinda similar to

#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8))

@Keno you added those lines, was #ifdef __GNUC__ meant to check for GCC or what?

@giordano
Copy link
Contributor Author

Looks like we might have to set -fgnuc-version: stackoverflow.com/questions/38499462/how-to-tell-clang-to-stop-pretending-to-be-other-compilers

That appears to be available only from LLVM 10, while Julia should be buildable with with LLVM >= 3.5. I think checking for __clang__ would be a better approach, if that was indeed the goal of __GNUC__.

@Keno
Copy link
Member

Keno commented Feb 28, 2022

As the comment above says, it depends on the C version default, so maybe check for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants