You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/28 09:21:05 UTC

[GitHub] [incubator-nuttx-apps] pussuw opened a new pull request, #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

pussuw opened a new pull request, #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157

   lxx must be before lmm at least, because new uses malloc().
   
   ## Summary
   Fixes C++ library linkage with CONFIG_BUILD_KERNEL
   ## Impact
   
   ## Testing
   icicle:knsh
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pkarashchenko merged pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pussuw commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1111976522

   > What is the exact error with the current code? I mean do we use start/end group for the libs? Otherwise I do not see why order should matter here
   
   libcxx refers to e.g. malloc which is in libmm, the ordering matters here, otherwise e.g. malloc will be left undefined in applications that use libxx but don't use malloc directly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pussuw commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112945999

   > I think you are hitting this issue [apache/incubator-nuttx#6082](https://github.com/apache/incubator-nuttx/issues/6082)
   
   That issue is different I think, it is on the export side. What I face is that when linking e.g. cxxtest app, the resulting elf file has undefined symbols after ELFLD. Please keep in mind that this is with CONFIG_BUILD_KERNEL, every application is build separately into one .elf file which can be started e.g. via posix_spawn(), so this is quite different from the monolithic build process used by BUILD_FLAT and even BUILD_PROTECTED.
   
   ```
   /apps/bin_copy$ objdump -t cxxtest_stripped | grep UND
   0000000000000000         *UND*	0000000000000000 malloc
   0000000000000000         *UND*	0000000000000000 on_exit
   0000000000000000         *UND*	0000000000000000 syslog
   0000000000000000         *UND*	0000000000000000 free
   ```
   
   The problem I think is ELFLD does not have the start/end group encapsulation, like the kernel side does:
   `$(LDSTARTGROUP) $(LDLIBS) $(EXTRA_LIBS) $(LDENDGROUP)`
   
   
   ```
   define ELFLD
   	@echo "LD: $2"
   	$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDLIBS) -o $2
   endef
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] gustavonihei commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112572090

   > There is no cli error, the error comes from the elf loader because it encounters an undefined symbol it cannot resolve / relocate. I'll provide a more detailed error description tomorrow, but the short description is referencing symbols from libxx to e.g. symbols in libmm. The kernel mode ldlibs flag does not show start/end group. LDELF is called and there is no encapsulation either. All I know that appending lxx results in undefined symbols in the resulting cxx application elf.
   > 
   > Maybe the fix is to add usage of start/end group to kernel mode ldflags
   
   https://github.com/apache/incubator-nuttx-apps/blob/a5a4c561fb9c9c5c9af0013f2c3b8901a176b956/Application.mk#L133-L136
   
   If adding wrapping `LDLIBS` with `LDSTARTGROUP` and `LDENDGROUP` works, I believe this would be the definitive fix for the issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pussuw commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112580192

   
   > 
   > If wrapping `LDLIBS` with `LDSTARTGROUP` and `LDENDGROUP` works, I believe this would be the definitive fix for the issue.
   
   Agreed, I'll try that tomorrow
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] gustavonihei commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112549893

   I agree with @pkarashchenko. NuttX usually wraps the libraries around `--start-group` and `--end-group` (via `LDSTARTGROUP` and `LDENDGROUP`), so the ordering of libraries should not matter because those libraries within the group will be searched repeatedly until all symbols are found.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pkarashchenko commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112552721

   @pussuw maybe you can share the command line call that generates an error so we can take a look at the arguments that are passed during the link stage?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pussuw commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112565673

   There is no cli error, the error comes from the elf loader because it encounters an undefined symbol it cannot resolve / relocate. I'll provide a more detailed error description tomorrow, but the short description is references to symbols in libxx to e.g. symbols in libmm. The kernel mode ldlibs flag does not show start/end group. LDELF is called and there is no encapsulation either. All I know that appending lxx results in undefined symbols in the resulting cxx application elf.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pkarashchenko commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112948666

   > $(LDSTARTGROUP) $(LDLIBS) $(LDENDGROUP) fixes the issue, thanks for the help guys
   
   Great!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pussuw commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112948371

   $(LDSTARTGROUP) $(LDLIBS) $(LDENDGROUP) fixes the issue, thanks for the help guys


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pkarashchenko commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1112918403

   I think you are hitting this issue https://github.com/apache/incubator-nuttx/issues/6082


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] pkarashchenko commented on pull request #1157: import/Make.defs: Fix C++ library linkage with CONFIG_BUILD_KERNEL

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #1157:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1157#issuecomment-1111969837

   What is the exact error with the current code?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org