public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] LoongArch: Link c++ header directory in the default ABI to the toplevel.
       [not found] <20230906100628.26033-1-yangyujie@loongson.cn>
@ 2023-09-06 10:38 ` Xi Ruoyao
  2023-09-07  3:09   ` Yang Yujie
  0 siblings, 1 reply; 2+ messages in thread
From: Xi Ruoyao @ 2023-09-06 10:38 UTC (permalink / raw)
  To: Yang Yujie, gcc-patches
  Cc: richard.sandiford, xuchenghua, chenglulu, libstdc++

On Wed, 2023-09-06 at 18:06 +0800, Yang Yujie wrote:
> When multilib is enabled, the c++ header directory of the default multilib
> variant needs to be linked to the toplevel since g++ does not search the
> toplevel in this case.
> 
> libstdc++-v3/ChangeLog:
> 
>         * configure.host: Register t-loongarch in tmake_file.
>         * config/cpu/loongarch/t-loongarch: New file.  Link c++ header
>         directory in the default ABI to the toplevel.
> ---
>  libstdc++-v3/config/cpu/loongarch/t-loongarch | 12 ++++++++++++
>  libstdc++-v3/configure.host                   |  5 ++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
>  create mode 100644 libstdc++-v3/config/cpu/loongarch/t-loongarch
> 
> diff --git a/libstdc++-v3/config/cpu/loongarch/t-loongarch
> b/libstdc++-v3/config/cpu/loongarch/t-loongarch
> new file mode 100644
> index 00000000000..942eddeb3be
> --- /dev/null
> +++ b/libstdc++-v3/config/cpu/loongarch/t-loongarch
> @@ -0,0 +1,12 @@
> +LA_DEFAULT_MULTIDIR = $(shell $(CXX) --print-multi-directory)
> +TOPLEV_HEADERS = $(DESTDIR)${gxx_include_dir}/${host_alias}/$(LA_DEFAULT_MULTIDIR)
> +
> +.PHONY: install-toplevel-link
> +install: install-toplevel-link
> +install-toplevel-link:
> +       if test x$(MULTIDO) != xtrue && \
> +          test x$(LA_DEFAULT_MULTIDIR) != x.; then \
> +           $(MKDIR_P) "$(dir $(TOPLEV_HEADERS))"; \
> +           rm -rf "$(TOPLEV_HEADERS)"; \
> +           $(LN_S) ../ "$(TOPLEV_HEADERS)"; \

From autoconf info page:

 -- Macro: AC_PROG_LN_S
     If ‘ln -s’ works on the current file system (the operating system
     and file system support symbolic links), set the output variable
     ‘LN_S’ to ‘ln -s’; otherwise, if ‘ln’ works, set ‘LN_S’ to ‘ln’,
     and otherwise set it to ‘cp -pR’.

     If you make a link in a directory other than the current directory,
     its meaning depends on whether ‘ln’ or ‘ln -s’ is used.  To safely
     create links using ‘$(LN_S)’, either find out which form is used
     and adjust the arguments, or always invoke ‘ln’ in the directory
     where the link is to be created.

     In other words, it does not work to do:
          $(LN_S) foo /x/bar

     Instead, do:

          (cd /x && $(LN_S) foo bar)

But for this special case we cannot "cp -pR ../ $(TOPLEV_HEADERS)"
either:

$ cp ../* -pR something
cp: cannot copy a directory, '../g', into itself, 'h/g'

So I guess we'll need something like

if ln -s ../ "$(TOPLEV_HEADERS)"; then
  # OK!
  true
else
  # system does not support symlink :(
  # install another copy of toplevel headers into default multilib subdir
  TODO: ????????
fi

And all libstdc++ patches should Cc: libstdc++@gcc.gnu.org.

> +       fi
> diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
> index 9e7c7f02dfd..9dc42ad3edb 100644
> --- a/libstdc++-v3/configure.host
> +++ b/libstdc++-v3/configure.host
> @@ -315,7 +315,10 @@ esac
>  # Set any OS-dependent and CPU-dependent bits.
>  # THIS TABLE IS SORTED.  KEEP IT THAT WAY.
>  case "${host}" in
> -  *-*-linux* | *-*-uclinux*)
> + loongarch*)
> +    tmake_file="cpu/loongarch/t-loongarch"
> +    ;;
> + *-*-linux* | *-*-uclinux*)
>      case "${host_cpu}" in
>        i[567]86)
>          abi_baseline_pair=i486-linux-gnu

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] LoongArch: Link c++ header directory in the default ABI to the toplevel.
  2023-09-06 10:38 ` [PATCH] LoongArch: Link c++ header directory in the default ABI to the toplevel Xi Ruoyao
@ 2023-09-07  3:09   ` Yang Yujie
  0 siblings, 0 replies; 2+ messages in thread
From: Yang Yujie @ 2023-09-07  3:09 UTC (permalink / raw)
  To: Xi Ruoyao
  Cc: Yang Yujie, gcc-patches, richard.sandiford, xuchenghua,
	chenglulu, libstdc++

On Wed, Sep 06, 2023 at 06:38:25PM +0800, Xi Ruoyao wrote:
> On Wed, 2023-09-06 at 18:06 +0800, Yang Yujie wrote:
> > When multilib is enabled, the c++ header directory of the default multilib
> > variant needs to be linked to the toplevel since g++ does not search the
> > toplevel in this case.
> > 
> > libstdc++-v3/ChangeLog:
> > 
> >         * configure.host: Register t-loongarch in tmake_file.
> >         * config/cpu/loongarch/t-loongarch: New file.  Link c++ header
> >         directory in the default ABI to the toplevel.
> > ---
> >  libstdc++-v3/config/cpu/loongarch/t-loongarch | 12 ++++++++++++
> >  libstdc++-v3/configure.host                   |  5 ++++-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> >  create mode 100644 libstdc++-v3/config/cpu/loongarch/t-loongarch
> > 
> > diff --git a/libstdc++-v3/config/cpu/loongarch/t-loongarch
> > b/libstdc++-v3/config/cpu/loongarch/t-loongarch
> > new file mode 100644
> > index 00000000000..942eddeb3be
> > --- /dev/null
> > +++ b/libstdc++-v3/config/cpu/loongarch/t-loongarch
> > @@ -0,0 +1,12 @@
> > +LA_DEFAULT_MULTIDIR = $(shell $(CXX) --print-multi-directory)
> > +TOPLEV_HEADERS = $(DESTDIR)${gxx_include_dir}/${host_alias}/$(LA_DEFAULT_MULTIDIR)
> > +
> > +.PHONY: install-toplevel-link
> > +install: install-toplevel-link
> > +install-toplevel-link:
> > +       if test x$(MULTIDO) != xtrue && \
> > +          test x$(LA_DEFAULT_MULTIDIR) != x.; then \
> > +           $(MKDIR_P) "$(dir $(TOPLEV_HEADERS))"; \
> > +           rm -rf "$(TOPLEV_HEADERS)"; \
> > +           $(LN_S) ../ "$(TOPLEV_HEADERS)"; \
> 
> From autoconf info page:
> 
>  -- Macro: AC_PROG_LN_S
>      If ‘ln -s’ works on the current file system (the operating system
>      and file system support symbolic links), set the output variable
>      ‘LN_S’ to ‘ln -s’; otherwise, if ‘ln’ works, set ‘LN_S’ to ‘ln’,
>      and otherwise set it to ‘cp -pR’.
> 
>      If you make a link in a directory other than the current directory,
>      its meaning depends on whether ‘ln’ or ‘ln -s’ is used.  To safely
>      create links using ‘$(LN_S)’, either find out which form is used
>      and adjust the arguments, or always invoke ‘ln’ in the directory
>      where the link is to be created.
> 
>      In other words, it does not work to do:
>           $(LN_S) foo /x/bar
> 
>      Instead, do:
> 
>           (cd /x && $(LN_S) foo bar)
> 
> But for this special case we cannot "cp -pR ../ $(TOPLEV_HEADERS)"
> either:
> 
> $ cp ../* -pR something
> cp: cannot copy a directory, '../g', into itself, 'h/g'
> 
> So I guess we'll need something like
> 
> if ln -s ../ "$(TOPLEV_HEADERS)"; then
>   # OK!
>   true
> else
>   # system does not support symlink :(
>   # install another copy of toplevel headers into default multilib subdir
>   TODO: ????????
> fi
> 
> And all libstdc++ patches should Cc: libstdc++@gcc.gnu.org.
> 
> > +       fi
> > diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
> > index 9e7c7f02dfd..9dc42ad3edb 100644
> > --- a/libstdc++-v3/configure.host
> > +++ b/libstdc++-v3/configure.host
> > @@ -315,7 +315,10 @@ esac
> >  # Set any OS-dependent and CPU-dependent bits.
> >  # THIS TABLE IS SORTED.  KEEP IT THAT WAY.
> >  case "${host}" in
> > -  *-*-linux* | *-*-uclinux*)
> > + loongarch*)
> > +    tmake_file="cpu/loongarch/t-loongarch"
> > +    ;;
> > + *-*-linux* | *-*-uclinux*)
> >      case "${host_cpu}" in
> >        i[567]86)
> >          abi_baseline_pair=i486-linux-gnu
> 
> -- 
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University

Thanks for the review!

After some tweaking, it appeared that we can simply override
${multisubdir} in configure.host and achieve the same.

I will upload another patch soon.

Yujie


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-07  3:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230906100628.26033-1-yangyujie@loongson.cn>
2023-09-06 10:38 ` [PATCH] LoongArch: Link c++ header directory in the default ABI to the toplevel Xi Ruoyao
2023-09-07  3:09   ` Yang Yujie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).