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

libxx:fix build error when enable LIBCXXTOOLCHAIN #13663

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

crafcat7
Copy link
Contributor

Summary

Fixed #13648

The problem is that when LIBCXXTOOLCHAIN ​​is enabled, LIBCXXMINI is included in the compilation. This causes a conflict between the void* operator new in the toolchain and the LIBCXXMINI.
When LIBCXXTOOLCHAIN ​​is enabled in the configuration, the version provided by the toolchain should be used.

  P:➜  nuttx git:(4cec713dbf) LC_ALL=C make
CC:  chip/stm32_gpio.c chip/stm32_gpio.c:41:11: note: '#pragma message: CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py'
   41 | #  pragma message "CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py"
      |           ^~~~~~~
CXX:  libcxxmini/libxx_new.cxx libcxxmini/libxx_new.cxx:72:11: error: redefinition of 'void* operator new(std::size_t, void*)'
   72 | FAR void *operator new(std::size_t nbytes, FAR void *ptr)
      |           ^~~~~~~~
In file included from /usr/include/newlib/c++/13.2.1/bits/atomic_base.h:36,
                 from /usr/include/newlib/c++/13.2.1/atomic:41,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/atomic.h:32,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/fs/fs.h:38,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/lib/lib.h:30,
                 from libcxxmini/libxx_new.cxx:29:
/usr/include/newlib/c++/13.2.1/new:174:33: note: 'void* operator new(std::size_t, void*)' previously defined here
  174 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                 ^~~~~~~~
make[1]: *** [Makefile:69: libxx_new.o] Error 1
make: *** [tools/LibTargets.mk:216: libs/libxx/libxx.a] Error 2

Impact

Is a new feature added?: NO
Impact on build: NO
**Impact on hardware:**NO, this change does not specifically target any particular hardware architectures or boards.
Impact on documentation: NO,This patch does not introduce any new features
Impact on compatibility: This implementation aims to be backward compatible. No existing functionality is expected to be broken.

Testing

Build Host(s): Linux x86
Target(s): stm32f411e-disco:nsh
Build Success

make -j        
Create version.h
LN: platform/board to /home/crafcat7/SSD/apps/platform/dummy
Register: nsh
Register: sh
CC:  semaphore/sem_rw.c chip/stm32_gpio.c:41:11: note: '#pragma message: CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py'
   41 | #  pragma message "CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py"
      |           ^~~~~~~
CPP:  /home/crafcat7/SSD/nuttx/boards/arm/stm32/stm32f411e-disco/scripts/f411ve.ld-> /home/crafcat7/SSD/nuttx/boards/arm/stm32/stm32f411e-disco/scLD: nuttx
CP: nuttx.hex
CP: nuttx.bin

@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Sep 27, 2024
@xiaoxiang781216
Copy link
Contributor

@crafcat7 let's update cmake too.

@crafcat7
Copy link
Contributor Author

@crafcat7 let's update cmake too.

Done,I push again

Summary:
  P:➜  nuttx git:(4cec713) LC_ALL=C make
CC:  chip/stm32_gpio.c chip/stm32_gpio.c:41:11: note: '#pragma message: CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py'
   41 | #  pragma message "CONFIG_STM32_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py"
      |           ^~~~~~~
CXX:  libcxxmini/libxx_new.cxx libcxxmini/libxx_new.cxx:72:11: error: redefinition of 'void* operator new(std::size_t, void*)'
   72 | FAR void *operator new(std::size_t nbytes, FAR void *ptr)
      |           ^~~~~~~~
In file included from /usr/include/newlib/c++/13.2.1/bits/atomic_base.h:36,
                 from /usr/include/newlib/c++/13.2.1/atomic:41,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/atomic.h:32,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/fs/fs.h:38,
                 from /home/leduc/wdc_workspace/src/autre/nuttx_dev/nuttx/include/nuttx/lib/lib.h:30,
                 from libcxxmini/libxx_new.cxx:29:
/usr/include/newlib/c++/13.2.1/new:174:33: note: 'void* operator new(std::size_t, void*)' previously defined here
  174 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                 ^~~~~~~~
make[1]: *** [Makefile:69: libxx_new.o] Error 1
make: *** [tools/LibTargets.mk:216: libs/libxx/libxx.a] Error 2

Signed-off-by: chenrun1 <[email protected]>
@xiaoxiang781216 xiaoxiang781216 merged commit 0d46c68 into apache:master Sep 27, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Regression when building with C++ toolchain enabled
3 participants