Skip to content

Fix build failure on older Ubuntu - #6085

Merged
tlively merged 3 commits into
mainfrom
fix-build-failure
Nov 7, 2023
Merged

tlively merged 3 commits into
mainfrom
fix-build-failure

Conversation

@tlively

@tlively tlively commented Nov 6, 2023 •

Copy link
Copy Markdown
Member

Update the C++20 builder to use Ubuntu 20.04 to catch problems building with its system compiler. Also fix such a problem in wasm-fuzz-lattices.cpp.

Change one of the CI builders to use an older ubuntu to try to reproduce the
build failure.
@tlively

tlively commented Nov 6, 2023

Copy link
Copy Markdown
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@tlively tlively changed the title [WIP] Reproduce emsdk builder [WIP] Reproduce emsdk build failure Nov 6, 2023
@tlively
tlively marked this pull request as ready for review November 6, 2023 21:32
@tlively

tlively commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

Huzzah! The build is fixed! Shall we keep the change to the C++20 builder here to avoid similar problems in the future?

@tlively
tlively requested a review from kripken November 7, 2023 00:11
@tlively tlively changed the title [WIP] Reproduce emsdk build failure Fix build failure on older Ubuntu Nov 7, 2023
@tlively tlively mentioned this pull request Nov 7, 2023

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What was wrong with the current code exactly? Was it using some new feature? Or is the old ubuntu compiler just buggy/wrong?

Comment thread .github/workflows/ci.yml
name: c++20
runs-on: ubuntu-latest
# Make sure we can still build on older Ubuntu
runs-on: ubuntu-20.04

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great! Thanks for doing this.

Vector<RandomFullLattice>,
TupleFullLattice>;

struct RandomFullLattice::LatticeImpl : FullLatticeVariant {};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this "subclass without adding anything" a workaround for a compiler bug, or a C++ spec requirement, or something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Even before this PR, we had to subclass without adding anything because we had to defer defining these nested types until their outer types (RandomFullLattice and RandomLattice) were complete. Since using statements cannot be forward declared, we had no choice but to forward declare LatticeImpl (previously L) as separate structs.

This PR just gives a name to the raw std::variant<...> superclasses as well and uses those newly-named types down below where we call std::visit.

@tlively

tlively commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

What was wrong with the current code exactly? Was it using some new feature? Or is the old ubuntu compiler just buggy/wrong?

It seems that the implementation of std::visit on the older ubuntu did not Just Work when passed subclasses of std::variant rather than the std::variant itself. Stack Overflow suggests this was a gcc bug: https://stackoverflow.com/questions/51309467/using-stdvisit-on-a-class-inheriting-from-stdvariant-libstdc-vs-libc

@tlively
tlively merged commit 0167c65 into main Nov 7, 2023
@tlively
tlively deleted the fix-build-failure branch November 7, 2023 17:28
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Update the C++20 builder to use Ubuntu 20.04 to catch problems building with its
system compiler. Also fix such a problem in wasm-fuzz-lattices.cpp.
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.

3 participants