Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mips64 support #54

Open
justincormack opened this issue Dec 14, 2013 · 14 comments
Open

mips64 support #54

justincormack opened this issue Dec 14, 2013 · 14 comments

Comments

@justincormack
Copy link
Member

Now seems close to working

Expects to have _LP64 defined so need along the lines of (plus for big endian)

diff --git a/buildrump.sh b/buildrump.sh
index da16891..5e16657 100755
--- a/buildrump.sh
+++ b/buildrump.sh
@@ -1011,7 +1011,7 @@ evaltarget ()
                else
                        MACHINE="evbmips64-el"
                        MACH_ARCH="mips64el"
-                       EXTRA_CFLAGS='-fPIC -D__mips_n64 -mabi=64'
+                       EXTRA_CFLAGS='-fPIC -D__mips_n64 -mabi=64 -D_LP64'
                        EXTRA_LDFLAGS='-D__mips_n64 -mabi=64'
                        EXTRA_AFLAGS='-fPIC -D__mips_n64 -mabi=64'
                fi

sys/rump/librump/rumpkern/arch/mips/Makefile.inc always defines ARCH_ELFSIZE=32 should be like sys/rump/librump/rumpkern/arch/powerpc/Makefile.inc which tests for which one to use.

However patching for those all the tests are segfaulting so something else is wrong.

@anttikantee
Copy link
Member

There was some weird black magic involved with forcing ARCH_ELFSIZE=32. You better ask matt@netbsd.org if you want to change it.

Why do you force -fPIC? Isn't it better to force MKSTATICLIB=no?

@justincormack
Copy link
Member Author

The black magic seems to be less so, its simply the rumpkern Makefile unconditionally setting it and the lack of _LP64 meaning a condition sets it wrong, its much cleaner than before.

I seem to remember the -fPIC was due to some MIPS instruction set oddness, will check again, once I find out why everything segfaults...

@justincormack
Copy link
Member Author

without -fPIC you get

/home/justin/buildrump.sh/obj/tooldir/bin/mips64el--netbsd-gcc  -Wl,-x -shared -Wl,-soname,librump.so.0 -Wl,--warn-shared-textrel -Wl,-Map=librump.so.0.map   -D__mips_n64 -mabi=64  -Wl,-T,/home/justin/buildrump.sh/src/lib/librump/../../sys/rump/ldscript.rump  -o librump.so.0.0   -Wl,--whole-archive librump.a  -Wl,--no-whole-archive -L/home/justin/buildrump.sh/obj/lib/librumpuser -lrumpuser 
/usr/lib/gcc/mips64el-unknown-linux-gnu/4.7.3/../../../../mips64el-unknown-linux-gnu/bin/ld: librump.a(ptree.o): relocation R_MIPS_HI16 against `__gnu_local_gp' can not be used when making a shared object; recompile with -fPIC
librump.a(ptree.o): could not read symbols: Bad value

SO looks like something was compiled without -fPIC that should be...

@anttikantee
Copy link
Member

If can propose changing the ARCH_ELFSIZE on some NetBSD list (e.g. port-mips) and nobody objects, I can change it.

For the second one, note that the shared lib is being build from the .a, not the _pic.a. bsd.own.mk claims:

# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC),
# not just shared libraries, so don't build the _pic version.
#
.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
    ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb"
MKPICLIB:=      no
.endif

So would be interesting to know, why this doesn't hold. You compiler doesn't use abicalls?

@justincormack
Copy link
Member Author

ARCH_ELFSIZE is correctly defined elsewhere in src/sys/arch/mips/include/elf_machdep.h it is only sys/rump/librump/rumpkern/arch/mips/Makefile.inc that has it wrong.

src/sys/arch/mips/include/elf_machdep.h:

#ifdef _LP64
#define ARCH_ELFSIZE            64      /* MD native binary size */
#else
#define ARCH_ELFSIZE            32      /* MD native binary size */
#endif

So adding the same ifdef to librump seems trivially correct...

@justincormack
Copy link
Member Author

On the -fPIC issue it seems the correct thing is to add -mabicalls instead, which is not the default. Testing this.

@anttikantee
Copy link
Member

Well, there was some big lossage with ARCH_ELFSIZE, and note that the Makefile definition postdates the ARCH_ELFSIZE stuff in elf_machdep.h

Anyway, ARCH_ELFSIZE should only affect code which grovels with ELF data structures.

@justincormack
Copy link
Member Author

There is some code that uses ELF data structures somewhere, although most of the errors are just about redefinitions. What do you mean "big lossage"?

@justincormack
Copy link
Member Author

-mabicalls without -fPIC still doesn;t work... suspect MKPICLIB=yes may be better behaved...

@anttikantee
Copy link
Member

I don't quite remember the details, it was >4 years ago. I think some builds broke due to assumptions that the mip64 code made.

Hard to say what's the right way to proceed with the PIC libs, I don't know enough about the MIPS ABIs, and my copy of See MIPS Run is in a box !here.

@justincormack
Copy link
Member Author

Fixed issues with big endian mips. I think merging the mips and mips64 selection code in buildrump.sh probably sane.

@justincormack
Copy link
Member Author

I should put my notes into this ticket... not sure where I put them. The ARCH_ELFSIZE thing is a weird mips-ism, whereby they use 32bit elf format is used on 64 bit kernels for booting reasons, a process that requires some munging. This makes no real sense for rump, which should just use the normal platform elf, so it needs some rump conditionals to fix.

The PIC issues are due to historical issues where all mips code is supposed to be PIC anyway, so you do not need to build special pic/nopic object files. But your (non Netbsd) host may not be set up to actually build fully pic, hence the flags tweaking which is also on 32 bit, where -fPIC is added.

@anttikantee
Copy link
Member

Building machine-level atomic ops would be nice too, but don't think it's strictly speaking required for support (see list in rumpkern/Makefile.rumpkern)

@justincormack
Copy link
Member Author

I am not convinced that the toolchain I currently have on my mips boxes generates working mips64 code, I think I need to experiment with a mips64 native build. However the following patch lets it compile:

diff --git a/sys/rump/librump/rumpkern/arch/mips/Makefile.inc b/sys/rump/librump/rumpkern/arch/mips/Makefile.inc
index a3283c0..7a3e746 100644
--- a/sys/rump/librump/rumpkern/arch/mips/Makefile.inc
+++ b/sys/rump/librump/rumpkern/arch/mips/Makefile.inc
@@ -1,6 +1,10 @@
 # $NetBSD: Makefile.inc,v 1.2 2014/02/12 22:28:43 pooka Exp $

+.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
 CPPFLAGS+= -DARCH_ELFSIZE=32
+.else
+CPPFLAGS+= -DARCH_ELFSIZE=64
+.endif

 .PATH: ${RUMPTOP}/librump/rumpkern/arch/generic
 SRCS+=     rump_generic_cpu.c rump_generic_kobj.c rump_generic_pmap.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants