Loki-Astari / ThorsMongo

C++ MongoDB API and BSON/JSON Serialization library
GNU General Public License v3.0
316 stars 72 forks source link

[Linuxbrew] Trying to prepare v2.2.0 bottle but hitting compilation issues (tried GCC-11 and LLVM) #73

Closed cho-m closed 3 years ago

cho-m commented 3 years ago

Describe the bug Issue is building ThorsSerializer for Linux as part of Homebrew/Linuxbrew distribution.

Attempt here: https://github.com/Homebrew/homebrew-core/pull/81472

Trying with GCC-11 fails on coverage test linking BsonPrinter:

g++-11 -o coverage/unittest.app -DCOVERAGE_test -DTHOR_COVERAGE      ERROR
export RPATH=/usr/local/lib;
g++-11 -o coverage/unittest.app coverage/SerSetTest.o coverage/PolyMorphicSerializerUniquePointerTest.o coverage/YamlPrinterTest.o coverage/DeprecatedTest.o coverage/TemplateTypeTest.o coverage/BankAccountTest.o coverage/SerDequeTest.o coverage/IgnoreUneededDataTest.o coverage/OverrideIdentiferToKeyMapTest.o coverage/SerVectorTest.o coverage/YamlParserTest.o coverage/SerMapTest.o coverage/SerInitializerListTest.o coverage/SerMemoryTest.o coverage/CornerCaseTest.o coverage/Issue72Test.o coverage/unittest.o coverage/SerMultiMapTest.o coverage/SerUnorderedMultiSetTest.o coverage/Issue42Test.o coverage/SerTuppleTest.o coverage/BsonParserTest.o coverage/SerUnorderedSetTest.o coverage/HomeBrewTest.o coverage/Issue49Test.o coverage/EscapeControlTest.o coverage/RoundTripTest.o coverage/StaticMemberTest.o coverage/SerializeEnumTest.o coverage/Issue50Test.o coverage/LexerTest.o coverage/SerUnorderedMapTest.o coverage/SerListTest.o coverage/Logging.o coverage/ReferenceWrapperTest.o coverage/SerializeTest.o coverage/PolymorphicTest.o coverage/BsonUtilitySerializationTest.o coverage/ParserInterfaceTest.o coverage/BsonLongArrayTest.o coverage/SmartPointerTest.o coverage/PointerTest.o coverage/BsonPrinterTest.o coverage/JsonPrinterTest.o coverage/SerUnorderedMultiMapTest.o coverage/SerMultiSetTest.o coverage/Issue38Test.o coverage/JsonParserTest.o coverage/TwitterTest.o coverage/UnicodeIteratorTest.o coverage/Issue51Test.o coverage/SerArrayTest.o coverage/ExceptionWhilePrintingTest.o coverage/FilterValuesTest.o coverage/unittest.o -L./coverage -lUnitTest -L../coverage -L/tmp/thors-serializer-20210719-9466-1qqwrfl/build/dlib -L/tmp/thors-serializer-20210719-9466-1qqwrfl/build/lib -lgtest -fprofile-arcs -ftest-coverage -lpthread -L/tmp/thors-serializer-20210719-9466-1qqwrfl/build/lib -lThorsLogging17D -L/usr/local/lib -lyaml -ldl
===================================================
/home/linuxbrew/.linuxbrew/bin/ld: coverage/PolyMorphicSerializerUniquePointerTest.o: in function `ThorsAnvil::Serialize::SerializeMember<PolyMorphicSerializerUniquePointerTest::AbstractTourResult, std::unique_ptr<PolyMorphicSerializerUniquePointerTest::Quantities, std::default_delete<PolyMorphicSerializerUniquePointerTest::Quantities> >, ThorsAnvil::Serialize::Traits<std::remove_cv<std::unique_ptr<PolyMorphicSerializerUniquePointerTest::Quantities, std::default_delete<PolyMorphicSerializerUniquePointerTest::Quantities> > >::type>::type> ThorsAnvil::Serialize::make_SerializeMember<PolyMorphicSerializerUniquePointerTest::AbstractTourResult, std::unique_ptr<PolyMorphicSerializerUniquePointerTest::Quantities, std::default_delete<PolyMorphicSerializerUniquePointerTest::Quantities> > >(ThorsAnvil::Serialize::Serializer&, ThorsAnvil::Serialize::PrinterInterface&, PolyMorphicSerializerUniquePointerTest::AbstractTourResult const&, std::pair<char const*, std::unique_ptr<PolyMorphicSerializerUniquePointerTest::Quantities, std::default_delete<PolyMorphicSerializerUniquePointerTest::Quantities> > PolyMorphicSerializerUniquePointerTest::AbstractTourResult::*> const&) [clone .isra.0]':
PolyMorphicSerializerUniquePointerTest.cpp:(.text+0xa3c): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<4ul, int>(int)'
/home/linuxbrew/.linuxbrew/bin/ld: coverage/PolyMorphicSerializerUniquePointerTest.o: in function `ThorsAnvil::Serialize::BsonPrinter::addValue(int)':
PolyMorphicSerializerUniquePointerTest.cpp:(.text._ZN10ThorsAnvil9Serialize11BsonPrinter8addValueEi[_ZN10ThorsAnvil9Serialize11BsonPrinter8addValueEi]+0xd): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<4ul, int>(int)'
/home/linuxbrew/.linuxbrew/bin/ld: coverage/Issue42Test.o: in function `ThorsAnvil::Serialize::BsonPrinter::addValue(double)':
Issue42Test.cpp:(.text._ZN10ThorsAnvil9Serialize11BsonPrinter8addValueEd[_ZN10ThorsAnvil9Serialize11BsonPrinter8addValueEd]+0xd): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeFloat<8ul, double>(double)'
/home/linuxbrew/.linuxbrew/bin/ld: coverage/Issue42Test.o: in function `void ThorsAnvil::Serialize::printPolyMorphicObject<Issue42Test::Vehicle>(ThorsAnvil::Serialize::Serializer&, ThorsAnvil::Serialize::PrinterInterface&, Issue42Test::Vehicle const&)':
Issue42Test.cpp:(.text._ZN10ThorsAnvil9Serialize22printPolyMorphicObjectIN11Issue42Test7VehicleEEEvRNS0_10SerializerERNS0_16PrinterInterfaceERKT_[_ZN10ThorsAnvil9Serialize22printPolyMorphicObjectIN11Issue42Test7VehicleEEEvRNS0_10SerializerERNS0_16PrinterInterfaceERKT_]+0x1e1): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<4ul, int>(int)'
/home/linuxbrew/.linuxbrew/bin/ld: coverage/BsonPrinterTest.o: in function `BsonPrinterTest_ArrayWithArrayValues_Test::TestBody()':
BsonPrinterTest.cpp:(.text+0x25a8): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<4ul, int>(int)'
/home/linuxbrew/.linuxbrew/bin/ld: BsonPrinterTest.cpp:(.text+0x25d5): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeFloat<8ul, double>(double)'
/home/linuxbrew/.linuxbrew/bin/ld: BsonPrinterTest.cpp:(.text+0x25ea): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<8ul, long>(long)'
/home/linuxbrew/.linuxbrew/bin/ld: BsonPrinterTest.cpp:(.text+0x25ff): undefined reference to `void ThorsAnvil::Serialize::BsonPrinter::writeInt<8ul, long long>(long long)'

Also, GCC doesn't like copyright character and we needed to strip that out of file:

In file included from FrameTest.cpp:51:
testlist.h:7:13: error: extended character © is not valid in an identifier
    7 | # Copyright © 2013 Bart Massey
      |             ^

We also tried with LLVM-12, but it also had issues.

Expected behavior Successfully build for Linux via Linuxbrew since it is documented installation method in repo. We are also trying to merge Linuxbrew into Homebrew and want to bottle (pre-build) everything for Linux.

Environment: GitHub CI: https://github.com/Homebrew/homebrew-core/runs/3111009018

Can't run command, but general details are:

Kernel: Linux 5.8.0-1036-azure x86_64 GNU/Linux
OS: Ubuntu 16.04.7 LTS (xenial)
Host glibc: 2.23

This is a Docker container running on GitHub ubuntu-latest

Running Homebrew/Linuxbrew GCC-11 https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcc.rb

Additional context

Add any other context about the problem here.

Loki-Astari commented 3 years ago

Do you have a link to your linux environment. I'll try and reproduce and fix.

Currently this builds on travis-ci.com (Linux version) which is where I test Linux builds.

cho-m commented 3 years ago

This is on Homebrew's CI node using GitHub actions

Loki-Astari commented 3 years ago

I have a fork of the homebrew-core. Are there instructions on how to get this build working using "Github Workflow"

I have pushed an update that I think should fix your issues.

Not sure how to get the Workflows actions to build it.

https://github.com/Loki-Astari/homebrew-core/actions

cho-m commented 3 years ago

I saw your PR and labeled it for Linux CI run.

I am not aware of how to get CI running in a fork. I also had some issues trying this due to some brew test-bot failures. Probably need Homebrew maintainer who worked on the CI to comment.

Loki-Astari commented 3 years ago

There is still an issue. I need to tinker with the autotools files to prevent a check for python (when vera is not being used).

cho-m commented 3 years ago

Sure, no rush.

We had worked around that by just adding Python as build dependency in https://github.com/Homebrew/homebrew-core/pull/81472/files, e.g.

  on_linux do
    depends_on "python@3.9" => :build
  end

...

  def install
    ENV["COV"] = "gcov"
    on_linux do
      ENV["PYTHON"] = Formula["python@3.9"].opt_bin/"python3"
    end
Loki-Astari commented 3 years ago

If fixed most issues. The one that remains is because you are trying to compile with C++11.

There is a minimum requirement of C++17. Is there a way to express this in the formula file?

cho-m commented 3 years ago

You need to disable the default compiler (gcc 5) and add dependency to another compiler. For Linux, we usually try latest gcc (11).

  on_linux do
    depends_on "gcc" # uses C++17
  end

  fails_with gcc: "5"
Loki-Astari commented 3 years ago

Latest update now seems to build on all environments.

cho-m commented 3 years ago

Thanks for the support. Closing as issue is resolved and bottle is now built for Linux.