Hi, Alex

> After the sed command, there is #include <sys/cdefs-32.h> which requires
> special non-default arrangements in the build system, specifically, using 
> libbsd in
> overlay mode with special compiler flags as described in the man page you 
> refer
> to. But that's not the only way to use libbsd, and the other way won't work.


Reference to the man page, libbsd recommends overlay mode.
"The library can be used in an overlay mode, which is the preferred way, so 
that the code is portable and requires no modification to the original BSD 
code......."

From the build log and the source code of libbsd, I found that libbsd does 
provide header file in overlay mode by default as the man page says. 
-----------------------------------------------------------------------
$ ls tmp/work/cortexa57-poky-linux/libbsd/0.12.2/image/usr/lib64/pkgconfig/
libbsd-ctor.pc  libbsd-overlay.pc  libbsd.pc
$ grep include tmp/work/cortexa57-poky-linux/libbsd/0.12.2/temp/log.do_compile 
-r
...... -I.. -isystem ../../libbsd-0.12.2/include/bsd/......
...... -I.. -isystem ../../libbsd-0.12.2/include/bsd/......
......
$ vim 
tmp/work/cortexa57-poky-linux/libbsd/0.12.2/libbsd-0.12.2/include/bsd/stringlist.h
#ifdef LIBBSD_OVERLAY
#include <sys/cdefs.h>
#else
#include <bsd/sys/cdefs.h>
#endif
#include <sys/types.h>
----------------------------------------------------------------------

And I Investigated several OSS(e.g. shadow, mg, libxdmcp) that depend on 
libbsd. From the source code of theirs. I found that they does used libbsd in 
overlay mode by default. 
Such as shadow:
-----------------------------------------------------------------------
vim 
tmp/work/cortexa57-poky-linux/shadow/4.15.0/shadow-4.15.0/lib/readpassphrase.h
......
#ifdef LIBBSD_OVERLAY
#include <sys/cdefs.h>
#endif
......
-----------------------------------------------------------------------

The same as mg :
-----------------------------------------------------------------------
$ vim tmp/work/cortexa57-poky-linux/mg/20230501/git/CMakeLists.txt
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
  pkg_check_modules (BSD REQUIRED libbsd-overlay)
  link_directories (${BSD_LIBRARY_DIRS})
  string (REPLACE ";" " " LIBBSD_FLAGS "${BSD_CFLAGS}")
  target_link_libraries (mg ${BSD_LIBRARIES})
  set (CMAKE_C_FLAGS "-Wall -DREGEX -D_GNU_SOURCE ${LIBBSD_FLAGS} 
${NCURSES_FLAGS} -L${NCURSES_LIBRARY_DIRS}")
else()
  set (CMAKE_C_FLAGS "-Wall -DREGEX ${LIBBSD_FLAGS} ${NCURSES_FLAGS} 
-L${NCURSES_LIBRARY_DIRS}")
endif()
-----------------------------------------------------------------------

So, I think the header file after oe_multilib_header should be in overlay mode 
as the other header files in libbsd.
Of course, If added "#ifdef LIBBSD_OVERLAY" into the header file after 
oe_multilib_header, libbsd will have a better compatibility. What do you think?


Best regards
Lei




> -----Original Message-----
> From: Alexander Kanavin <[email protected]>
> Sent: Thursday, April 25, 2024 4:08 PM
> To: Lei, Maohui <[email protected]>
> Cc: [email protected]
> Subject: Re: [OE-core][PATCH v3] libbsd: Fix conflict error when enable 
> multilib.
> 
> On Thu, 25 Apr 2024 at 07:52, leimaohui via lists.openembedded.org
> <[email protected]> wrote:
> > - After oe_multilib_header on cdefs.h, the path of cdefs-64.h and 
> > cdefs-32.h in
> cdefs.h need to be corrected. Please reference to
> https://man.archlinux.org/man/libbsd.7 for details.
> 
> I looked at this in a local build, and I actually don't think they need to be
> corrected. Without the sed command, there is #include <bsd/sys/cdefs-32.h>,
> which is fine, as it's relative to /usr/include, and unambigious.
> 
> After the sed command, there is #include <sys/cdefs-32.h> which requires
> special non-default arrangements in the build system, specifically, using 
> libbsd in
> overlay mode with special compiler flags as described in the man page you 
> refer
> to. But that's not the only way to use libbsd, and the other way won't work.
> 
> So what is the issue that happens if there is no sed, and only
> oe_multilib_header?
> 
> Alex
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#198712): 
https://lists.openembedded.org/g/openembedded-core/message/198712
Mute This Topic: https://lists.openembedded.org/mt/105725841/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to