Re: [PATCH] configure: detect version by compiler for build

Subject: Re: [PATCH] configure: detect version by compiler for build

Date: Tue, 28 Jul 2020 07:18:31 +0700

To: Tomi Ollila

Cc: notmuch@notmuchmail.org

From: Đoàn Trần Công Danh


On 2020-07-27 20:31:59+0300, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Mon, Jul 27 2020, Đoàn Trần Công Danh wrote:
> 
> > We'll need to run the compiled binary to report our current version.
> >
> > With the same code base, we should have the same version information
> > regardless of compiler and architecture.
> >
> > Let's use the compiler for building architecture to build the reporting
> > binary. Which is usually reported under variable CC_FOR_BUILD,
> > a convention established by GNU Autotools, and fall back to CC if it's
> > not defined.
> 
> We'd probably need to change quite a few other compiled and run binaries
> in configure... otherwise this would be incomplete change (and thus just
> adds confusion ?)

Other compile and try run linked with libraries in (autotools') host
architecture.

Linking with build's libraries doesn't make sense, hence I ignored it.
And patched downstream.

I don't mind dropping this change and carry it downstream.

> 
> >
> > Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
> > ---
> >  configure | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/configure b/configure
> > index 98f5f1ea..db3538b3 100755
> > --- a/configure
> > +++ b/configure
> > @@ -85,8 +85,10 @@ fi
> >  BASHCMD=${BASHCMD:-bash}
> >  PERL=${PERL:-perl}
> >  CC=${CC:-cc}
> > +CC_FOR_BUILD=${CC_FOR_BUILD:-$CC}
> >  CXX=${CXX:-c++}
> >  CFLAGS=${CFLAGS:--g -O2}
> > +CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:-$CFLAGS}
> >  CPPFLAGS=${CPPFLAGS:-}
> >  CXXFLAGS_for_sh=${CXXFLAGS:-${CFLAGS}}
> >  CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
> > @@ -410,7 +412,7 @@ int main(void) {
> >      return 0;
> >  }
> >  EOF
> > -if ${CC} ${CFLAGS} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
> > +if ${CC_FOR_BUILD} ${CFLAGS_FOR_BUILD} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
> >         && ./_libversion > _libversion.sh && . ./_libversion.sh
> >  then
> >      printf "OK.\n"
> > -- 
> > 2.28.0.rc2.21.g5c06d60fc5
> > _______________________________________________
> > notmuch mailing list -- notmuch@notmuchmail.org
> > To unsubscribe send an email to notmuch-leave@notmuchmail.org

-- 
Danh
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: