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

Compile Software with gcc instead of clang #1129

Closed
wants to merge 32 commits into from

Conversation

jonathanlew
Copy link
Contributor

@jonathanlew jonathanlew commented Jan 20, 2020

Please fill out the following before requesting review on this PR

Description

Use native gcc to compile code instead of external clang package.

  • Replaced magic_enum because magic_enum only works on gcc 9
  • Some tweaks to some tests
  • Some compiler error fixes

Testing Done

Resolved Issues

resolves #1124

Length Justification

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue
  • Justify drops in code coverage: If this PR results in a non-trivial drop in code coverage (a bot should post a coverage diagram as a comment), please justify why we can't test the code that's not covered.

Copy link
Contributor Author

@jonathanlew jonathanlew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few interesting bits for reviewers to look at

# See the License for the specific language governing permissions and
# limitations under the License.

exec /usr/bin/x86_64-linux-gnu-gcc -Wl,--no-as-needed "$@"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garethellis0 can you do better than this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I don't immediately see a better way 😢. I'm fine with this as long as we leave a comment and open an issue with https://github.com/bazelbuild/bazel asking if this is the correct behavior. I can do make the issue or you can, just lemme know!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drafting an email to [email protected] according to this message:

ATTENTION! Please read and follow:

  • if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to [email protected]
  • if this is a bug or feature request, fill the form below as best as you can.

Copy link
Contributor

@garethellis0 garethellis0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Will try to find a way to put this compiler flags in the toolchain now........

Copy link
Contributor

@MathewMacDougall MathewMacDougall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good. Still seems to be some clang stuff floating around in files that got renamed like
src/cc_toolchain/wrapper/clang-profdata → src/cc_toolchain/wrapper/k8_gcc-profdata
src/cc_toolchain/wrapper/clang-strip → src/cc_toolchain/wrapper/k8_gcc-strip

"/usr/include/",
"/usr/local/include/",
"/usr/lib/gcc/c++/7.4.0/include/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, we explicitly have the include directory for 7.4.0 because we still depend on libs / code built with that version of gcc, so this is where we need to look to find it? Do we have any guarantee this folder exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ubuntu 18.04 has gcc 7.4.0 preinstalled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should install gcc 7.4.0 explicitly in the setup scripts @garethellis0 ? I don't reall want to have stuff just magically assumed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with me, installing gcc-7 should do the trick I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done


filegroup(
name = "k8_gcc_libs",
srcs = glob(["usr/lib/gcc/x86_64-linux-gnu/7.4.0/*.a"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my previous comment, should this really all be specifying 7.4.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu 18.04 should have 7.4.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question here is can we make this a bit more general, ie. usr/lib/gcc/x86_64-linux-gnu/*/*.a or maybe usr/lib/gcc/x86_64-linux-gnu/*/*.a, but I think that could cause issues if there are multiple versions of gcc installed. perhaps we could make this a filegroup in the arm_gcc.BUILD file, just so that all the version-specific stuff is in one place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'm mostly just concerned about us

  1. Expecting a specific version of gcc that we do nothing to verify exists
  2. "hardcoding" the version in multiple places

I just want this to be easy to upgrade and change in the future, and not cause errors with non-obvious messages if someone without the right setup tries to compile

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to filegroup them any better. I think I can reduce changes required to update just src/external/k8_gcc.BUILD

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue here is maybe more in the naming. Could we rename this file to linux_gcc_7_4_0, because that's how specific it is? Similairly, everything in this file should probably be changed from k8_gcc to linux_gcc_7_4_0.

This way if we ever go to upgrade the compiler version or even support multiple platforms, it's clear what bits are specific to what.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good now

@MathewMacDougall
Copy link
Contributor

Only remaining comment for me is gcc versioning, otherwise nothing more to add beyond existing comments (and CI needs to pass).

@garethellis0
Copy link
Contributor

Looks like there was a small (but somewhat nasty) bug where we were relying on just reading random memory here. Opened a quick PR to this branch to fix: https://github.com/jonathanlew/Software/pull/1/files

@jonathanlew
Copy link
Contributor Author

Added back the clang-format binary so CI should pass now

@jonathanlew
Copy link
Contributor Author

@garethellis0 @MathewMacDougall re-review?

@garethellis0
Copy link
Contributor

Looks like CI failed due to a network issue. Re-running now.

Copy link
Contributor

@garethellis0 garethellis0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main comments from my end here are just around what we call k8_gcc vs linux_gcc_7_4_0.

Also one comment left above from an earlier review.

Overall looking good! This will definitely be an improvement.


filegroup(
name = "k8_gcc_libs",
srcs = glob(["usr/lib/gcc/x86_64-linux-gnu/7.4.0/*.a"]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue here is maybe more in the naming. Could we rename this file to linux_gcc_7_4_0, because that's how specific it is? Similairly, everything in this file should probably be changed from k8_gcc to linux_gcc_7_4_0.

This way if we ever go to upgrade the compiler version or even support multiple platforms, it's clear what bits are specific to what.

Copy link
Contributor

@MathewMacDougall MathewMacDougall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing major to add beyond Gareth's comments. Can we also change the setup scripts to ensure we install gcc 7.4.0?

@jonathanlew
Copy link
Contributor Author

Ready for re-review

Copy link
Contributor

@garethellis0 garethellis0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job getting comments resolved! Just one left (at the very top) and then this is good to go from my end!

@jonathanlew
Copy link
Contributor Author

Nice job getting comments resolved! Just one left (at the very top) and then this is good to go from my end!

Will email [email protected] re: -Wl,--no-as-needed in linux_gcc-gcc

jonathanlew and others added 2 commits February 9, 2020 20:39
Co-Authored-By: Gareth Ellis <[email protected]>
@MathewMacDougall
Copy link
Contributor

Seems like this is good to go then? @garethellis0 is everything good from your end?

@garethellis0
Copy link
Contributor

Still waiting on code coverage here..... not sure why it's not running, I think Jon is going to open a new PR to see if that fixes it?

@jonathanlew
Copy link
Contributor Author

Will close and reopen to try to fix coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile Software with gcc instead of clang
3 participants