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

Build compatibility with Clang 10 and Ubuntu 20.04 #6600

Closed
rhuanjl opened this issue Feb 5, 2021 · 5 comments
Closed

Build compatibility with Clang 10 and Ubuntu 20.04 #6600

rhuanjl opened this issue Feb 5, 2021 · 5 comments

Comments

@rhuanjl
Copy link
Collaborator

rhuanjl commented Feb 5, 2021

CC fails to build on Ubuntu 20 with the following output, this should be fixed ASAP:

[1/690] Building CXX object pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/file.cpp.o
FAILED: pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/file.cpp.o 
/usr/bin/clang++ -DBIT64=1 -DCAN_BUILD_WABT -DCLANG_HAS_DISABLE_TAIL_CALLS=1 -DDBG=1 -DDBG_DUMP=1 -DDEBUG=1 -DFEATURE_PAL -DFEATURE_PAL=1 -DHAS_ICU -DHAS_REAL_ICU=1 -DINTL_ICU=1 -DLINUX64 -DLP64COMPATIBLE=1 -DPIC=1 -DPLATFORM_UNIX=1 -DSTACK_ALIGN=16 -DTARGET_64 -DUNICODE -D_AMD64_ -D_CHAKRACOREBUILD -D_DEBUG=1 -D_FILE_OFFSET_BITS=64 -D_M_AMD64 -D_M_X64 -D_SAFECRT_USE_CPP_OVERLOADS=1 -D_WIN64=1 -D__LINUX__=1 -D__STDC_WANT_LIB_EXT1__=1 -Ipal/src -I../pal/src -I../. -I../lib/Common -I../lib/Common/PlaceHolder -I../pal -I../pal/inc -I../pal/inc/rt -I../pal/src/include -Werror         -Wno-ignored-attributes        -Wno-parentheses-equality        -Wno-reorder        -Wno-microsoft        -Wno-unused-value        -Wno-int-to-void-pointer-cast        -Wno-invalid-offsetof        -Wno-undefined-inline        -Wno-inconsistent-missing-override        -Wno-c++14-extensions        -Wno-macro-redefined        -Wno-pragmas        -Wno-invalid-token-paste        -Wno-format        -Wno-invalid-noreturn        -Wno-null-arithmetic        -Wno-tautological-constant-out-of-range-compare        -Wno-tautological-undefined-compare        -Wno-address-of-temporary        -Wno-null-conversion        -Wno-return-type        -Wno-switch        -Wno-int-to-pointer-cast        -Wno-tautological-constant-compare        -Wno-enum-compare-switch        -Wno-unknown-warning-option                  -fno-omit-frame-pointer         -fdelayed-template-parsing -g   -fdiagnostics-color=always -msse4.2 -fasm-blocks -fms-extensions -fwrapv -fstack-protector -fno-builtin -fPIC -std=gnu++11 -MD -MT pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/file.cpp.o -MF pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/file.cpp.o.d -o pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/file.cpp.o -c ../pal/src/cruntime/file.cpp
In file included from ../pal/src/cruntime/file.cpp:23:
In file included from ../pal/src/include/pal/palinternal.h:553:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stdlib.h:36:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstdlib:75:
/usr/include/stdlib.h:112:36: error: exception specification in declaration does not match previous declaration
__extension__ extern long long int atoll (const char *__nptr)
                                   ^
../pal/inc/pal.h:6198:33: note: previous declaration is here
PALIMPORT long long int __cdecl atoll(const char *);
                                ^
1 error generated.
[2/690] Building CXX object pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/filecrt.cpp.o
FAILED: pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/filecrt.cpp.o 
/usr/bin/clang++ -DBIT64=1 -DCAN_BUILD_WABT -DCLANG_HAS_DISABLE_TAIL_CALLS=1 -DDBG=1 -DDBG_DUMP=1 -DDEBUG=1 -DFEATURE_PAL -DFEATURE_PAL=1 -DHAS_ICU -DHAS_REAL_ICU=1 -DINTL_ICU=1 -DLINUX64 -DLP64COMPATIBLE=1 -DPIC=1 -DPLATFORM_UNIX=1 -DSTACK_ALIGN=16 -DTARGET_64 -DUNICODE -D_AMD64_ -D_CHAKRACOREBUILD -D_DEBUG=1 -D_FILE_OFFSET_BITS=64 -D_M_AMD64 -D_M_X64 -D_SAFECRT_USE_CPP_OVERLOADS=1 -D_WIN64=1 -D__LINUX__=1 -D__STDC_WANT_LIB_EXT1__=1 -Ipal/src -I../pal/src -I../. -I../lib/Common -I../lib/Common/PlaceHolder -I../pal -I../pal/inc -I../pal/inc/rt -I../pal/src/include -Werror         -Wno-ignored-attributes        -Wno-parentheses-equality        -Wno-reorder        -Wno-microsoft        -Wno-unused-value        -Wno-int-to-void-pointer-cast        -Wno-invalid-offsetof        -Wno-undefined-inline        -Wno-inconsistent-missing-override        -Wno-c++14-extensions        -Wno-macro-redefined        -Wno-pragmas        -Wno-invalid-token-paste        -Wno-format        -Wno-invalid-noreturn        -Wno-null-arithmetic        -Wno-tautological-constant-out-of-range-compare        -Wno-tautological-undefined-compare        -Wno-address-of-temporary        -Wno-null-conversion        -Wno-return-type        -Wno-switch        -Wno-int-to-pointer-cast        -Wno-tautological-constant-compare        -Wno-enum-compare-switch        -Wno-unknown-warning-option                  -fno-omit-frame-pointer         -fdelayed-template-parsing -g   -fdiagnostics-color=always -msse4.2 -fasm-blocks -fms-extensions -fwrapv -fstack-protector -fno-builtin -fPIC -std=gnu++11 -MD -MT pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/filecrt.cpp.o -MF pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/filecrt.cpp.o.d -o pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/filecrt.cpp.o -c ../pal/src/cruntime/filecrt.cpp
In file included from ../pal/src/cruntime/filecrt.cpp:23:
In file included from ../pal/src/include/pal/thread.hpp:24:
In file included from ../pal/src/include/pal/corunix.hpp:25:
In file included from ../pal/src/include/pal/palinternal.h:553:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stdlib.h:36:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstdlib:75:
/usr/include/stdlib.h:112:36: error: exception specification in declaration does not match previous declaration
__extension__ extern long long int atoll (const char *__nptr)
                                   ^
../pal/inc/pal.h:6198:33: note: previous declaration is here
PALIMPORT long long int __cdecl atoll(const char *);
                                ^
1 error generated.
[3/690] Building CXX object pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/finite.cpp.o
FAILED: pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/finite.cpp.o 
/usr/bin/clang++ -DBIT64=1 -DCAN_BUILD_WABT -DCLANG_HAS_DISABLE_TAIL_CALLS=1 -DDBG=1 -DDBG_DUMP=1 -DDEBUG=1 -DFEATURE_PAL -DFEATURE_PAL=1 -DHAS_ICU -DHAS_REAL_ICU=1 -DINTL_ICU=1 -DLINUX64 -DLP64COMPATIBLE=1 -DPIC=1 -DPLATFORM_UNIX=1 -DSTACK_ALIGN=16 -DTARGET_64 -DUNICODE -D_AMD64_ -D_CHAKRACOREBUILD -D_DEBUG=1 -D_FILE_OFFSET_BITS=64 -D_M_AMD64 -D_M_X64 -D_SAFECRT_USE_CPP_OVERLOADS=1 -D_WIN64=1 -D__LINUX__=1 -D__STDC_WANT_LIB_EXT1__=1 -Ipal/src -I../pal/src -I../. -I../lib/Common -I../lib/Common/PlaceHolder -I../pal -I../pal/inc -I../pal/inc/rt -I../pal/src/include -Werror         -Wno-ignored-attributes        -Wno-parentheses-equality        -Wno-reorder        -Wno-microsoft        -Wno-unused-value        -Wno-int-to-void-pointer-cast        -Wno-invalid-offsetof        -Wno-undefined-inline        -Wno-inconsistent-missing-override        -Wno-c++14-extensions        -Wno-macro-redefined        -Wno-pragmas        -Wno-invalid-token-paste        -Wno-format        -Wno-invalid-noreturn        -Wno-null-arithmetic        -Wno-tautological-constant-out-of-range-compare        -Wno-tautological-undefined-compare        -Wno-address-of-temporary        -Wno-null-conversion        -Wno-return-type        -Wno-switch        -Wno-int-to-pointer-cast        -Wno-tautological-constant-compare        -Wno-enum-compare-switch        -Wno-unknown-warning-option                  -fno-omit-frame-pointer         -fdelayed-template-parsing -g   -fdiagnostics-color=always -msse4.2 -fasm-blocks -fms-extensions -fwrapv -fstack-protector -fno-builtin -fPIC -std=gnu++11 -MD -MT pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/finite.cpp.o -MF pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/finite.cpp.o.d -o pal/src/CMakeFiles/Chakra.Pal.dir/cruntime/finite.cpp.o -c ../pal/src/cruntime/finite.cpp
In file included from ../pal/src/cruntime/finite.cpp:22:
In file included from ../pal/src/include/pal/palinternal.h:553:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/stdlib.h:36:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstdlib:75:
/usr/include/stdlib.h:112:36: error: exception specification in declaration does not match previous declaration
__extension__ extern long long int atoll (const char *__nptr)
                                   ^
../pal/inc/pal.h:6198:33: note: previous declaration is here
PALIMPORT long long int __cdecl atoll(const char *);
                                ^
In file included from ../pal/src/cruntime/finite.cpp:24:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/math.h:36:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cmath:45:
In file included from /usr/include/math.h:307:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:159:1: error: exception specification in declaration does not match previous declaration
__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
^
/usr/include/math.h:278:3: note: expanded from macro '__MATHCALLX'
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
/usr/include/math.h:280:3: note: expanded from macro '__MATHDECLX'
  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  ^
/usr/include/math.h:283:15: note: expanded from macro '__MATHDECL_1'
  extern type __MATH_PRECNAME(function,suffix) args __THROW
              ^
/usr/include/math.h:303:34: note: expanded from macro '__MATH_PRECNAME'
# define __MATH_PRECNAME(name,r) name##f##r
                                 ^
<scratch space>:56:1: note: expanded from here
ceilf
^
../pal/inc/pal.h:6403:25: note: previous declaration is here
PALIMPORT float __cdecl ceilf(float);
                        ^
In file included from ../pal/src/cruntime/finite.cpp:24:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/math.h:36:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cmath:45:
In file included from /usr/include/math.h:307:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:165:1: error: exception specification in declaration does not match previous declaration
__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
^
/usr/include/math.h:278:3: note: expanded from macro '__MATHCALLX'
  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  ^
/usr/include/math.h:280:3: note: expanded from macro '__MATHDECLX'
  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  ^
/usr/include/math.h:283:15: note: expanded from macro '__MATHDECL_1'
  extern type __MATH_PRECNAME(function,suffix) args __THROW
              ^
/usr/include/math.h:303:34: note: expanded from macro '__MATH_PRECNAME'
# define __MATH_PRECNAME(name,r) name##f##r
                                 ^
<scratch space>:62:1: note: expanded from here
floorf
^
../pal/inc/pal.h:6401:25: note: previous declaration is here
PALIMPORT float __cdecl floorf(float);
                        ^
3 errors generated.
ninja: build stopped: subcommand failed.
##[error]Bash exited with code '1'.
##[section]Finishing: Build

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Feb 7, 2021

@Fly-Style @ppenzin does one of you have an Ubuntu 20 machine you could experiment with this on?

My preference would be to delete these PAL math methods if possible - will have to check if/how they're used and if/how the posix definitions of them differ to the windows CRT versions. (There's a reasonably chance they're not used at all - PAL has some stuff in that we don't actually use)

@ppenzin
Copy link
Member

ppenzin commented Feb 9, 2021

I just got a WSL instance with Ubuntu 20.

An example of the errors (MSVC failure is unrelated): https://dev.azure.com/ChakraCoreEngine/ChakraCore/_build/results?buildId=195

CMake part of the build works, but fails in compilation.

@ppenzin ppenzin changed the title Build fails on Ubuntu 20 Build compatibility with Clang 10 and Ubuntu 20.04 Feb 10, 2021
@ppenzin
Copy link
Member

ppenzin commented Feb 10, 2021

I've deleted libc-like symbols from pal in #6604, but there are a bunch of "declaration overloads template parameter" errors after that - they are not only coming from PAL, but also from data structures in main sources.

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Feb 10, 2021

Just found we had a previous issue for this which I'd forgotten about #6466

Also, CC builds on macOS with AppleClang 12 (which IS Clang 10) so was wondering why it would fail on linux.

This may be the issue, in our root CMakeLists.txt we specific C (-std=gnu99) and C++ (-std=gnu++11) standards versions when building on macOS but not when building on linux:

ChakraCore/CMakeLists.txt

Lines 280 to 312 in 47d31de

if(CC_TARGET_OS_LINUX OR CC_TARGET_OS_ANDROID)
set(CLR_CMAKE_PLATFORM_LINUX 1)
# OSX 10.12 Clang deprecates libstdc++ [See GH #1599]
# So, -Werror is linux only for now
# + Android ARM ABI shows ld warnings
# xplat-todo: Do we need this ?
if (NOT CC_TARGET_OS_ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Werror"
)
endif()
elseif(CC_TARGET_OS_OSX)
add_definitions(
-DPLATFORM_UNIX
)
if(NOT CC_XCODE_PROJECT)
set(OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET} CC")
if (${OSX_DEPLOYMENT_TARGET} STREQUAL " CC")
set(OSX_DEPLOYMENT_TARGET "10.9")
add_compile_options(-mmacosx-version-min=10.9)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
-mmacosx-version-min=10.9 -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-mmacosx-version-min=10.9 -std=gnu++11")
else()
set(OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
message(WARNING "-- !! macOS Deployment Target was set to $ENV{MACOSX_DEPLOYMENT_TARGET}. Using it as is.")
endif()
endif()
else()
message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}")
endif()

EDIT: not so sure - tried building without those and it still builds offline, but may still be a worth a try on linux

AND we also do this which should have the same effect for C++ though maybe not for C?

set(CMAKE_CXX_STANDARD 11)

@ppenzin
Copy link
Member

ppenzin commented Feb 11, 2021

This won't get added to C++ files, I just tried that, as well as moving the PAL definition. I am sure this is solvable though.

ppenzin added a commit to ppenzin/ChakraCore that referenced this issue Feb 12, 2021
Drive by cleanup - build all wabt files in the build directory.

Disambiguate template parameter names. Overloading a template parameter
by a declaration (including in parameters to nested templates) is
treated as an error by Clang 10.

PAL math and memory API clean up (also for chakra-core#6404). Remove PAL
redefintions of system functions with incompatible exception
declarations. Remove externally visible redifinitions of math and memory
management functions. Delete corresponding math function
implementations, as they pretty much call their system counterparts.
Hide memory management functions, since they are still used from inside
of PAL.

[CI] Use Ubuntu 20.04 image for default Linux builds. Change default
Linux image to Ubuntu 20.04. Add two extra build jobs for Ubuntu 18.04.

Closes chakra-core#6600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants