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

Cleanup and harmonize Carla server build to use Unreal sysroot #7151

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from

Conversation

berndgassmann
Copy link
Contributor

Ensure that actually only the unreal sysroot is deployed for all C as
well C++ compilations including dependencies. That ensures the server is
NOT anymore linked against the system glibc (which is in Ubuntu22.04
incompatible with the Unreal one).
Harmonized naming split into client/server (instead of libcpp and
libstdcpp) to ensure nothing mixed up (and there were things mixed up
before!)

Refactor C# Unreal build using CarlaRules base class to provide common
functionality. Fixing windows build without ROS2 and added intitial
windows build with ROS2

Minors:

  • Update osm2odr commit
  • Fix windows install scripts and forward arguments for building
    libcarla
  • Add some helper scripts to run under Linux

Description

Fixes #

Where has this been tested?

Ubunut 22.04, Ros2 humble, python 3.10
Windows 11, ahhh, no idea what python version there was installed, assume python3.10, but python is in each case irrelevant for this commit as it's mainly affecting the server build. Let's see if the CI builds under Windows (still) correctly

  • Platform(s): ...
  • Python version(s): ...
  • Unreal Engine version(s): ...

Possible Drawbacks

Ensure that actually only the unreal sysroot is deployed for all C as
well C++ compilations including dependencies. That ensures the server is
NOT anymore linked against the system glibc (which is in Ubuntu22.04
incompatible with the Unreal one).
Harmonized naming split into client/server (instead of libcpp and
libstdcpp) to ensure nothing mixed up (and there were things mixed up
before!)

Refactor C# Unreal build using CarlaRules base class to provide common
functionality. Fixing windows build without ROS2 and added intitial
windows build with ROS2

Minors:
- Update osm2odr commit
- Fix windows install scripts and forward arguments for building
libcarla
- Add some helper scripts to run under Linux
@berndgassmann berndgassmann requested a review from a team as a code owner February 15, 2024 14:55
@berndgassmann berndgassmann changed the base branch from master to dev February 15, 2024 14:56
Blyron and others added 3 commits March 26, 2024 13:24
Separate installation of clang/llvm in Ubuntu is not required anymore
since the UE4-clang/llvm is used for compilation of ALL dependencies to
ensure the exact required sysroot is used.
void throw_exception<std::exception>(const std::exception &);
}

#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

EOF is missing in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed by calling Util/Formatting/codeformat.py and placing .clang-format to LibCarla folder

@@ -14,14 +14,14 @@
#ifdef BOOST_NO_EXCEPTIONS

namespace boost {

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty space pls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed by calling Util/Formatting/codeformat.py and placing .clang-format to LibCarla folder

void throw_exception(const std::exception &e) {
carla::throw_exception(e);
}

void throw_exception(
const std::exception &e,
boost::source_location const & loc) {
boost::source_location const & ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Return back parameter name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done and added (void)loc as the second option to get rid of the compiler warning on this.

}

template void throw_exception<std::length_error>(const std::length_error &);
template void throw_exception<asio::service_already_exists>(const asio::service_already_exists &);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add parameter names please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. also the other exception functions in the other file

@Blyron
Copy link
Contributor

Blyron commented Mar 27, 2024

I have added couple comments on your code, additionally could you merge dev branch?

sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-10/bin/clang++ 180 &&
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-10/bin/clang 180 &&
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 180
sudo apt-get install build-essential cmake ninja-build libvulkan1 python-is-python3 python3 python3-dev python3-pip libpng-dev libtiff5-dev libjpeg-dev tzdata sed curl unzip autoconf libtool rsync libxml2-dev git git-lfs
Copy link
Contributor

Choose a reason for hiding this comment

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

g++ is required to build modules like ROS2 and pytorch.
Why do you think we should remove it from package installation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only the additional g++-7 is removed (as not required) and the corresponding update alternatives call
build-essentials should bring already the default system g++ with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch about the build-essential package!

I have addicional worries about this change:
If we define the g++ version as system default one, this implies CARLA could be possibly build with huge number of g++ versions, as many users are building CARLA and we don't have any info about what distro are the using. On my understanding, define g++ version as system default adds the next risks:

  • Sometimes code built with different g++ versions my conclude on build errors or new defects.
  • Is not clear for CARLA contributors what is the minimum requiered version of g++ to mantain build backward compatibility when creating PRs.
  • I'm not sure if ROS2 and pytorch libraries have some restriction about what versions of the comipler to use.
  • It's pracmatic (usable) for the contributors to have a default version of g++ that is tested by us and we ensure is working. Otherwise, they could potentially have to deal with non desired build errors and this will take extra time for them. Anyway, I think we should provide a mechanism to the contributors to build with different versions of g++, but we also should provide a default stable g++ version for the contributors who don't expect to lose time dealing by unestable CARLA build sysmtem.

What are your thoughts about it?

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 see, yes your fears make sense.
I would then approach from that side. Standard supported linux system is Ubuntu. Then I would go with the active LTS versions and support their standard g++ versions. Taking their EOL dates as supporting dates might be a bit too much as Ubuntu 14.04 goes EOL right now. So taking their "End of Standard Support" as basis might be more meaningful:
Ubuntu 22.04 LTS: June 2027, gcc-11
Ubuntu 20.04 LTS: April 2025, gcc-9
Therefore, I'd either define gcc-9 or gcc-11 as gold standard for now.

On pytorch, I don't know since I have to admit that I never worked so far with it on my own. On ROS2 the respective Ubuntu default compiler for sure works.

But if CARLA supports both active Ubuntu systems (and maybe have a build job for both of them in the background to ensure), then you don't need to install a specific version here. One should then rewrite the docu in the sense that the two active Ubuntu systems are supported. And if someone else with nother Linux-Distro wants to compile CALRA he/she should install either gcc-9 or gcc-11 (at the current point in time for sure ;-)
Still, then you don't need to change the build instructions for 22.04 and 20.04, and why not making the live harder for the restistent guys who are still using 18.04 or older; If they do use such old systems they should be aware of that and be able to handle to install other gcc versions on their own if they run into problems. Or they should just upgrade their system -- which is from system security perspective in each case adviceable.
The supported clang version is in each case clear, since it's the Unreal one... which will also change soon when swithing to Unreal 5.xx engine.
So you see: you might want to extend the notes in the docu around that topic a bit and "degrade" also 18.04 to a not adviced Linux -Distro, since it has some years "on the back" (don't know if one says that also in UK like that ... it's some German slang ;-)

Please discuss with the team and adapt the commit as you decide on your own. You should have the rights to do so, I believe.

Ah, so now it's Easter in Germany: Happy searching of Easter Eggs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy Easter!
We also celebrate Easter here at Barcelona :)

Copied Util/Formatting/clang-format to LibCarla/.clang-format
and formatted the Exception files (at least) to get rid of formatting
errors.
@berndgassmann
Copy link
Contributor Author

In terms of code formatting, the .clang-format can be placed in the respective folders with different content (so the Unreal part can get one with Unreal formatting style).
When having this in place one could even go one step further and make the codeformat.py call a pre-commit hook that is then always executed before commiting (don't ask me how to introduce this, but I've seen that at other repos recently and loved it immediately).
Then the formating of spaces and braces etc. is clear and one saves a lot of review-time; since persons tend to forget running codeformater if not automated ;-).

@@ -69,12 +75,6 @@ if not exist "%GT_BUILD_DIR%" (
cd "%GT_BUILD_DIR%"
echo %FILE_N% Generating build...

echo.%GENERATOR% | findstr /C:"Visual Studio" >nul && (
set PLATFORM=-A x64
Copy link
Contributor

Choose a reason for hiding this comment

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

I share some discusion where is mentioned that buiding without -A x64 flag casues build error in some environments:
#7237

I'm not sure about why this build errors are happening. I'm worried about removing this code could introduce more build errors like the described in the shared discussion. Coudl your share your thoughts about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point is that I had build errors on my windows machine on this. Otherwise I wouldn't have changed it. But if you look more detailed onto the diff, I've just moved the code in the batch-file some lines upwards to line 40 that it is more or less identical to the other files.
But I could imagine also what the problems of others where. If you look into line 19 I've added the GENERATOR variable to this (and other scripts) with empty definitions per default. So in the batch file the GENERATOR variable wasn't defined at all if nothing is passed by the command line options. Then the original code in line 72 does somehow fail.

Therefore, I've tried to follow the "copy exactly" formula and adapted all (most?) of the batch files to

  • define the GENERATOR somewhere at top BEFORE command argument parsing
  • put the (full) PLATFORM definition lines relatively close to the end of the coomand line parsing.

You see this pattern in the below batch files, too. That's then part of the "harmonizing" work of this PR.

@Blyron
Copy link
Contributor

Blyron commented Apr 15, 2024

Hey Bernd!

When launching a make clean I receive this error:

Util/BuildTools/Linux.mk:163: warning: overriding recipe for target 'downloadplugins'
Util/BuildTools/Linux.mk:142: warning: ignoring old recipe for target 'downloadplugins'
BuildUE4Plugins.sh: Cleaning intermediate files and folders.
BuildUE4Plugins.sh: StreetMap Success!
BuildCarlaUE4.sh: Using Unreal Engine at '/home/adas/UnrealEngine_4.26'
BuildCarlaUE4.sh: Cleaning intermediate files and folders.
BuildCarlaUE4.sh: Success!
BuildPythonAPI.sh: Cleaning intermediate files and folders.
BuildPythonAPI.sh: Success!
BuildLibCarla.sh: Cleaning intermediate files and folders.
BuildLibCarla.sh: Success!
BuildOSM2ODR.sh: Cleaning intermediate files and folders.
rm: invalid option -- 'c'
Try 'rm --help' for more information.
make: *** [Util/BuildTools/Linux.mk:34: clean.osm2odr] Error 1

Then when I do a make launch, this issue appears:

FAILED: LibCarla/cmake/test/CMakeFiles/libcarla_test_server_release.dir///source/test/common/test_buffer.cpp.o
/home/adas/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/bin/clang++ -DASIO_NO_EXCEPTIONS -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_NO_EXCEPTIONS -DLIBCARLA_ENABLE_PROFILER -DLIBCARLA_IMAGE_WITH_PNG_SUPPORT=true -DLIBCARLA_NO_EXCEPTIONS -DLIBCARLA_TEST_CONTENT_FOLDER="/home/adas/CARLA/carla/Build/test-content" -DLIBCARLA_WITH_GTEST -DPUGIXML_NO_EXCEPTIONS -I/home/adas/CARLA/carla/LibCarla/cmake/../source -I/home/adas/CARLA/carla/LibCarla/cmake/../source/third-party -I/home/adas/CARLA/carla/LibCarla/cmake/../source/test -isystem /home/adas/CARLA/carla/Build/boost-1.80.0-c10-install/include -isystem /home/adas/CARLA/carla/Build/rpclib-v2.2.1_c5-c10-server-install/include -isystem /home/adas/CARLA/carla/Build/gtest-1.8.1-c10-server-install/include -isystem /home/adas/CARLA/carla/LibCarla/cmake/test -std=c++14 -pthread -fPIC -Wall -Wextra -Wpedantic -Wdeprecated -Wshadow -Wuninitialized -Wunreachable-code -Wpessimizing-move -Wold-style-cast -Wnull-dereference -Wduplicate-enum -Wnon-virtual-dtor -Wheader-hygiene -Wconversion -Wfloat-overflow-conversion -std=c++14 -fPIC -stdlib=libc++ -DBOOST_NO_EXCEPTIONS -DASIO_NO_EXCEPTIONS --sysroot=/home/adas/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/ -isystem /home/adas/UnrealEngine_4.26/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1 -std=c++14 -pthread -fPIC -Wall -Wextra -Wpedantic -Wdeprecated -Wshadow -Wuninitialized -Wunreachable-code -Wpessimizing-move -Wold-style-cast -Wnull-dereference -Wduplicate-enum -Wnon-virtual-dtor -Wheader-hygiene -Wconversion -Wfloat-overflow-conversion -std=c++14 -fPIC -stdlib=libc++ -DBOOST_NO_EXCEPTIONS -DASIO_NO_EXCEPTIONS --sysroot=/home/adas/UnrealEngine_4.26/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/ -isystem /home/adas/UnrealEngine_4.26/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1 -O3 -DNDEBUG -MD -MT LibCarla/cmake/test/CMakeFiles/libcarla_test_server_release.dir///source/test/common/test_buffer.cpp.o -MF LibCarla/cmake/test/CMakeFiles/libcarla_test_server_release.dir///source/test/common/test_buffer.cpp.o.d -o LibCarla/cmake/test/CMakeFiles/libcarla_test_server_release.dir///source/test/common/test_buffer.cpp.o -c /home/adas/CARLA/carla/LibCarla/source/test/common/test_buffer.cpp
In file included from /home/adas/CARLA/carla/LibCarla/source/test/common/test_buffer.cpp:7:
In file included from /home/adas/CARLA/carla/LibCarla/cmake/../source/test/test.h:13:
In file included from /home/adas/CARLA/carla/LibCarla/cmake/../source/test/Buffer.h:9:
In file included from /home/adas/CARLA/carla/LibCarla/cmake/../source/carla/Buffer.h:9:
/home/adas/CARLA/carla/LibCarla/cmake/../source/carla/Debug.h:71:12: fatal error: 'gtest/gtest.h' file not found

include <gtest/gtest.h>

- Move gcc-7 to gcc-13 since that's the default compiler on Ubuntu
24.4LTS.
- Fix make clean
- Fix make launch (without ROS2 args)
- Fixed wrong syntax in Linux.mk
- Fix missing ROS2 include when compiled without ROS
- Remove Util/Running folder again
- Remove LibCarla/.clang-format file
@berndgassmann
Copy link
Contributor Author

I wasn't able to reproduce the gtest.h issue, even uninstalling my ros2-humble packages including gtest headers. Nevertheless I've found other compilation issues, which I fixed ;-)

berndgassmann and others added 4 commits April 15, 2024 16:02
commit def46b8edc34e470caea445423add114eedf6585
Author: Bernd Gassmann <bernd.gassmann@intel.com>
Date:   Thu Apr 18 16:27:08 2024 +0200

    Fix proj and asio build

    checkout the proj 7.2 branch with required compilation fixes on newer
    systems

    let asio only install the data instead of compiling the tests/examples
    which we don't want/need
@berndgassmann berndgassmann force-pushed the berndgassmann/compile_ros2_against_unreal_dependencies branch from b78bd19 to 940271a Compare May 2, 2024 12:16
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.

None yet

3 participants