public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yang Yujie <yangyujie@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>
Cc: Yang Yujie <yangyujie@loongson.cn>,
	gcc-patches@gcc.gnu.org,  richard.sandiford@arm.com,
	xuchenghua@loongson.cn, chenglulu@loongson.cn,
	 libstdc++@gcc.gnu.org
Subject: Re: [PATCH] LoongArch: Link c++ header directory in the default ABI to the toplevel.
Date: Thu, 7 Sep 2023 11:09:04 +0800	[thread overview]
Message-ID: <5pbsmgaqr3wmoxcxheke6sw4rpj6t7u3wefagbuyjla7bb6sy5@idq6q7r5i2eu> (raw)
In-Reply-To: <e93dfe099e02c6140071bdab184d653dad69cde6.camel@xry111.site>

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


      reply	other threads:[~2023-09-07  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230906100628.26033-1-yangyujie@loongson.cn>
2023-09-06 10:38 ` Xi Ruoyao
2023-09-07  3:09   ` Yang Yujie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5pbsmgaqr3wmoxcxheke6sw4rpj6t7u3wefagbuyjla7bb6sy5@idq6q7r5i2eu \
    --to=yangyujie@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).