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

linux: Fix compile using GCC #2038

Open
kphillisjr opened this issue Nov 17, 2016 · 9 comments
Open

linux: Fix compile using GCC #2038

kphillisjr opened this issue Nov 17, 2016 · 9 comments

Comments

@kphillisjr
Copy link
Contributor

This is sort of a big request, but fix compilation using GCC (version 5.4.0) on Ubuntu 16.04 LTS. Many Linux distributions use GCC as the default compiler.

@dilijev dilijev added this to the Backlog milestone Nov 17, 2016
@dilijev
Copy link
Contributor

dilijev commented Nov 17, 2016

This is out of scope for our current milestones and current roadmap but we'll keep this in mind. During our initial work bringing ChakraCore cross-platform, we decided it was best to focus on a single compiler toolchain.

You should be able to install a compatible version of clang on most distributions so this shouldn't be a blocking issue for you. :)

@obastemur
Copy link
Collaborator

As @dilijev mentioned, this is not one of the priorities we have at hand due to Clang does the job very well. However, supporting GCC would be really nice!

Added Accepting PRs on this. If there are community member(s) want to contribute fixes to GCC build (partially is also accepted) we would love to have them.

@ppenzin
Copy link
Member

ppenzin commented Apr 14, 2020

On the surface GCC builds fail because CMake passes Clang-only flags to the compiler. Unless there are any deeper issues underneath, this should be relatively easy to fix by testing which flavor of compiler flags the compiler supports, which is a good practice anyway.

Generally, rather than quietly depending on behavior specific to a particular compiler, it is a good practice to test for the required features and spellings of flags, and ultimately emit informative error messages when developer's compiler lacks something.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Feb 13, 2021

On macOS I've built with gcc successfully with the cmake files as they are, be curious to see what issues it has on linux at the moment

@ppenzin
Copy link
Member

ppenzin commented Feb 15, 2021

On earlier versions of Ubuntu C++ GCC was too old to accept new C++ flags:

ChakraCore/CMakeLists.txt

Lines 400 to 411 in e6c8f78

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${CXX_DO_NOT_OPTIMIZE_SIBLING_CALLS} \
-fno-omit-frame-pointer \
-fdelayed-template-parsing"
)
# CXX / CC COMPILER FLAGS
add_compile_options(
-fasm-blocks
-fms-extensions
-fwrapv # Treat signed integer overflow as two's complement
)

With 20.04 the situation is better, but there are some flags it won't take. What I can see right now is -fasm-blocks and -fcolor-diagnostics (latter is definitely a Clang spelling of the flag). We might be able to fix this if we distinguish between GCC and Clang spellings of compiler options. Also it would probably help to write a check for minimum GCC version, so that users don't try to build it with older compiler which comes with older Ubuntu.

Lesser issue the use of -Werror only on Linux: https://github.com/chakra-core/ChakraCore/blob/master/CMakeLists.txt#L281-L290

@ppenzin
Copy link
Member

ppenzin commented Feb 15, 2021

I was able to get through those by being inserting a check for GCC, but then it gets a bunch of type resolution errors from PAL. I can share CMake changes though.

@curtisman
Copy link
Contributor

ChakraCore depends on clang because clang emulate a lot of the MSVC compiler behavior. So beyond the flags, there is a whole bunch of things that needs to fix to start using more of the PAL.

I spend a couple hours to hack thru it just because I am curious and was able to get PAL and WABT to build.
Next in the build was Backend and there was a lot of error, and the change is getting big.

#6611 is the draft PR if you guys want to take it.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Feb 15, 2021

Looking at the size of the draft diff and the number of issues clearly I hadn't built CC with gcc on macOS, looked into what I'd done and found that on macOS usr/bin/g++ and usr/bin/gcc are renamed copies of clang - I don't know why apple did that but yeah....

@curtisman thanks for investigation - considering the size of it we're probably not going to get this in soon but really appreciate the starter/pointers in the right direction.

@ppenzin
Copy link
Member

ppenzin commented Feb 16, 2021

I think you need to get GCC from homebrew on OSX.

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

7 participants