Git Product home page Git Product logo

Comments (8)

jpsamper2009 avatar jpsamper2009 commented on August 20, 2024 1

@dirk-thomas At a basic level, we would like to use -ftree-vectorize and -grecord-gcc-switches:

  • -ftree-vectorize will affect the ABI
  • -grecord-gcc-switches will allow us to write tools that check that the different binaries are built with the same flags, so we can tell, for example, that a given package didn't add a problematic flag like -fsanitize=address

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

To clarify which compile options you are referring to (which affect ABI) can you please explicitly enumerate them.

I see a few problems with the described approach:

  • Plain CMake packages not using the function would still be subject to ABI incompatibilities.
  • In general we don't want to embed ROS specific values like this in ament* packages. Maybe ament_cmake_ros would be a better place. (Obviously that would raise the bar of the first bullet to include packages which use ament_cmake but not ament_cmake_ros.)

CMake toolchain files would be one proper way of ensuring the same compiler options are being used across multiple packages. Others would be passing CMAKE_CXX_STANDARD, CMAKE_CPP_FLAGS, etc. to CMake.

Should the compile options also be added to add_test?

The CMake function add_test doesn't build any code so I don't think compile options are relevant here.

from ament_cmake.

jpsamper2009 avatar jpsamper2009 commented on August 20, 2024

I like the idea of a toolchain file. I'll look into that and report back.

As for add_test: maybe I was thinking of packages like ament_add_gtest, where an executable is created, but I guess this scenario would be addressed by the toolchain file too

from ament_cmake.

jpsamper2009 avatar jpsamper2009 commented on August 20, 2024

@dirk-thomas I've looked into using a toolchain file, and I see two main drawbacks:

  1. The recommended way of setting a compiler options is with target_set_compile_option
    • Granted, this still leave the issue of plain CMake packages, in which case a toolchain file is still the better solution
  2. Having to type out the path to the toolchain file when calling colcon:
colcon build --cmake-args -DCMAKE_TOOLCHAIN_FILE="$(pwd)/path/to/toolchain.cmake"

I was thinking, I could just add the --cmake-args to the colcon defaults.yaml, but then I would have to hard-code the path, and I would have to change it for different workspaces. Or is there a way to have variables (e.g. PWD or current work directory) that can be used in the defaults.yaml?

I also realized I haven't answered the question about which flags affect the ABI. This article gives a good overview of compiler flags and their potential consequences

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

The recommended way of setting a compiler options is with target_set_compile_option
Granted, this still leave the issue of plain CMake packages, in which case a toolchain file is still the better solution

That is why a toolchain file is the preferred approach.

Having to type out the path to the toolchain file when calling colcon:

While that is certainly not convenient there is no reason this can't be improved. That would probably fall into the same category as colcon/colcon-core#168.

I could just add the --cmake-args to the colcon defaults.yaml, but then I would have to hard-code the path, and I would have to change it for different workspaces.

The downside of using defaults.yaml is that if you pass custom --cmake-args on the command line they will override your defaults. Using a mixin is probably more appropriate - but that doesn't solve the need for different configurations for different workspaces if it contains workspace specific paths.

I also realized I haven't answered the question about which flags affect the ABI. This article gives a good overview of compiler flags and their potential consequences

That doesn't really answer the question which of the flags you want to use.

from ament_cmake.

jpsamper2009 avatar jpsamper2009 commented on August 20, 2024

@dirk-thomas Would it be viable to extend colcon to allow variables in the defaults.yaml or metadata files?

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

Would it be viable to extend colcon to allow variables in the defaults.yaml or metadata files?

Of course 👍

from ament_cmake.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

Closing due to no activity. It also sounds like the direction is to address this on the build tool level instead.

from ament_cmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.