Waldek Kozaczuk <[email protected]> writes:
> On Wednesday, February 17, 2021 at 7:56:52 AM UTC-5 punit wrote:
[...]
> > On Fedora I cross-compile like this:
> > ./scripts/build mode=release image=tests fs=rofs -j$(nproc) arch=aarch64
> --create-disk
> > So in my case the CROSS_PREFIX is not set at all this would use x86_64
> > gcc and fix x86_64 version og libgcc_s.so
>
> Would you be averse to setting the CROSS_PREFIX before calling the build
> script? Something like -
>
> CROSS_PREFIX=aarch64-linux-gnu- ./scripts/build mode=release ...
>
> Would that not require arch anymore in this case? So how would it work
> on fedora?
You would still need to pass the "arch=" to the build. The '...' at the
end were meant to indicate that the rest of the invocation stays
unmodified.
export CROSS_PREFIX=aarch-linux-gnu-
./scripts/build mode=release image=tests fs=rofs -j$(nproc) arch=aarch64
--create-disk
> I was hesitating to drop the aarch64-linux-gnu- prefix but dropping the
> hard-coded defaults regarding paths for compiler prefixes / library
> locations will allow simplifying the build scripts and Makefiles. Think
> about all the places we've got aarch64 hard coded in the build system.
>
> Looking ahead, dropping the default will also reduce the churn when
> porting OSv to other architectures (RISC-V for example).
>
> What do you think?
>
> Not sure. On one hand, it would be nice for the changes to be
> backwards compatible so that we do not have to update the docs. On
> other hand, I agree with some of your points that it would make it
> easier to support RISC-V in future.
Good point - I am not updating the docs in the patches.
Thinking about it a bit, it would be better to split the changes and
focus this series on enabling cross-compilation on Debian like
distros. Let's do the backward incompatible changes to the build system
in a separate series.
I'll send the updated patches shortly.
Thanks,
Punit
> I wonder what others think. I guest a lot of that applies to other patch.
>
> > +libgcc_s_dir=$(dirname $(readlink -f $(${CC}
> -print-file-name=libgcc_s.so.1)))
> > +if [[ "$libgcc_s_path" == "libgcc_s.so.1" ]]; then
> >
> > Did you mean libgcc_s_dir? This also probably would not be correct.
>
> Indeed - it should've been libgcc_s_dir here.
> >
> > + cat <<-EOF
> > + Unable to resolve libgcc_s.so.1 using "${CC}".
> > + Looking in ../downloaded_packages/aarch64/gcc/install/lib64
> > + EOF
> > + libgcc_s_dir=$(readlink -f
> ../downloaded_packages/aarch64/gcc/install/lib64)
> > fi
> >
> > All in all, this does not work on Fedora.
> >
> > I think this is a more correct version:
> >
> > diff --git a/scripts/build b/scripts/build
> >
> > index 5fdcc7a8..b07dfd6e 100755
> >
> > --- a/scripts/build
> >
> > +++ b/scripts/build
> >
> > @@ -272,14 +272,20 @@ cd $OUT
> >
> >
> >
> > host_arch=$(uname -m)
> >
> > if [[ "$host_arch" == "x86_64" && "$arch" == 'aarch64' ]]; then
> >
> > - libgcc_s_path=$(${CROSS_PREFIX:-aarch64-linux-gnu-}gcc
> -print-file-name=libgcc_s.so.1)
> >
> > - if [[ "$libgcc_s_path" == "libgcc_s.so.1" ]]; then
> >
> > - libgcc_s_dir=$(readlink -f
> ../downloaded_packages/aarch64/gcc/install/lib64)
> >
> > - else
> >
> > - libgcc_s_dir=$(dirname $(readlink -f $libgcc_s_path))
> >
> > - fi
> >
> > + CC=${CROSS_PREFIX:-aarch64-linux-gnu-}gcc
> >
> > +else
> >
> > + CC=gcc
> >
> > +fi
> >
> > +
> >
> > +libgcc_s_path=$(${CC} -print-file-name=libgcc_s.so.1)
> >
> > +if [[ "$libgcc_s_path" == "libgcc_s.so.1" ]]; then
> >
> > + cat <<-EOF
> >
> > + Unable to resolve libgcc_s.so.1 using "${CC}".
> >
> > + Looking in ../downloaded_packages/aarch64/gcc/install/lib64
> >
> > + EOF
> >
> > + libgcc_s_dir=$(readlink -f
> ../downloaded_packages/aarch64/gcc/install/lib64)
> >
> > else
> >
> > - libgcc_s_dir=$(dirname $(readlink -f $(gcc
> -print-file-name=libgcc_s.so.1)))
> >
> > + libgcc_s_dir=$(dirname $(readlink -f $libgcc_s_path))
> >
> > fi
> >
> >
> >
> > if [ "$export" != "none" ]; then
> >
> > if [ "$export" != "none" ]; then
> > --
> > 2.29.2
>
> Not sure what happened there but your patch shows up with extra newlines.
>
> If you think that it is better to leave the CROSS_PREFIX defaults in
> place for aarch64 then this patch works too.
>
> Regards,
> Punit
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/87v9and73t.fsf%40stealth.