linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* LLVM for m68k completed (but not merged)
@ 2020-06-21 20:12 John Paul Adrian Glaubitz
  2020-06-23 15:34 ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 4+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-06-21 20:12 UTC (permalink / raw)
  To: Debian m68k; +Cc: linux-m68k

Hi!


I just received the news that the m68k backend for LLVM has been finished [1].

It has not been merged upstream yet (that will take some time), but it should
be usable now. I'm currently test-building it on Debian/m68k and it would probably
a good idea if more people give it a spin to help finding issues.

One issue I found is that CycleTimer has not been implemented. A quick fix is to
use the definition used by MIPS, i.e.:

diff --git a/llvm/utils/benchmark/src/cycleclock.h b/llvm/utils/benchmark/src/cycleclock.h
index 1b0f09359c9..88b7805faaf 100644
--- a/llvm/utils/benchmark/src/cycleclock.h
+++ b/llvm/utils/benchmark/src/cycleclock.h
@@ -161,7 +161,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
   struct timeval tv;
   gettimeofday(&tv, nullptr);
   return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
-#elif defined(__mips__)
+#elif defined(__mips__) || defined(__m68k__)
   // mips apparently only allows rdtsc for superusers, so we fall
   // back to gettimeofday.  It's possible clock_gettime would be better.
   struct timeval tv;

Thanks,
Adrian

> [1] https://github.com/M680x0/M680x0-mono-repo

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: LLVM for m68k completed (but not merged)
  2020-06-21 20:12 LLVM for m68k completed (but not merged) John Paul Adrian Glaubitz
@ 2020-06-23 15:34 ` John Paul Adrian Glaubitz
  2020-06-24  1:07   ` Finn Thain
  0 siblings, 1 reply; 4+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-06-23 15:34 UTC (permalink / raw)
  To: Debian m68k; +Cc: linux-m68k

Hi!

On 6/21/20 10:12 PM, John Paul Adrian Glaubitz wrote:
> I just received the news that the m68k backend for LLVM has been finished [1].
I have had a go at the code now and with some changes to clang, I can actually
cross-compile "Hello World" in C now, cross-compile it with clang and get a working
m68k executable [1].

> glaubitz@epyc:/tmp/llvm-build> ./bin/clang -target m68k-linux-gnu ~/hello.c -o hello.m68k
> glaubitz@epyc:/tmp/llvm-build> file hello.m68k 
> hello.m68k: ELF 32-bit MSB executable, Motorola m68k, 68020, version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, for GNU/Linux 3.2.0, not stripped
> glaubitz@epyc:/tmp/llvm-build> cp -av hello.m68k /local_scratch/glaubitz/
> 'hello.m68k' -> '/local_scratch/glaubitz/hello.m68k'
> glaubitz@epyc:/tmp/llvm-build> schroot -c sid-m68k-sbuild
> glaubitz@epyc:/tmp/llvm-build> uname -a
> Linux epyc 5.6.0-2-amd64 #1 SMP Debian 5.6.14-1 (2020-05-23) m68k GNU/Linux
> glaubitz@epyc:/tmp/llvm-build> /glaubitz/hello.m68k 
> Hello World!
> glaubitz@epyc:/tmp/llvm-build>

Adrian

> [1] https://github.com/M680x0/M680x0-mono-repo/pull/7

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: LLVM for m68k completed (but not merged)
  2020-06-23 15:34 ` John Paul Adrian Glaubitz
@ 2020-06-24  1:07   ` Finn Thain
  2020-06-24  7:42     ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 4+ messages in thread
From: Finn Thain @ 2020-06-24  1:07 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz; +Cc: Debian m68k, linux-m68k

On Tue, 23 Jun 2020, John Paul Adrian Glaubitz wrote:

> Hi!
> 
> On 6/21/20 10:12 PM, John Paul Adrian Glaubitz wrote:
> 
> > I just received the news that the m68k backend for LLVM has been 
> > finished [1].
> 
> I have had a go at the code now and with some changes to clang, I can 
> actually cross-compile "Hello World" in C now, cross-compile it with 
> clang and get a working m68k executable [1].
> 
> > glaubitz@epyc:/tmp/llvm-build> ./bin/clang -target m68k-linux-gnu ~/hello.c -o hello.m68k
> > glaubitz@epyc:/tmp/llvm-build> file hello.m68k 
> > hello.m68k: ELF 32-bit MSB executable, Motorola m68k, 68020, version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, for GNU/Linux 3.2.0, not stripped
> > glaubitz@epyc:/tmp/llvm-build> cp -av hello.m68k /local_scratch/glaubitz/
> > 'hello.m68k' -> '/local_scratch/glaubitz/hello.m68k'
> > glaubitz@epyc:/tmp/llvm-build> schroot -c sid-m68k-sbuild
> > glaubitz@epyc:/tmp/llvm-build> uname -a
> > Linux epyc 5.6.0-2-amd64 #1 SMP Debian 5.6.14-1 (2020-05-23) m68k GNU/Linux
> > glaubitz@epyc:/tmp/llvm-build> /glaubitz/hello.m68k 
> > Hello World!
> > glaubitz@epyc:/tmp/llvm-build>
> 
> Adrian
> 
> > [1] https://github.com/M680x0/M680x0-mono-repo/pull/7
> 

Very impressive! I imagine that creating an LLVM backend would be a 
massive undertaking.

Does this backend bring any benefits compared with gcc? E.g. will it help 
gain support for other languages, like rust?

Do you know if anyone has run the LLVM unit tests on Motorola silicon?

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

* Re: LLVM for m68k completed (but not merged)
  2020-06-24  1:07   ` Finn Thain
@ 2020-06-24  7:42     ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 4+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-06-24  7:42 UTC (permalink / raw)
  To: Finn Thain; +Cc: Debian m68k, linux-m68k

Hi Finn!

On 6/24/20 3:07 AM, Finn Thain wrote:
> Very impressive! I imagine that creating an LLVM backend would be a 
> massive undertaking.
> 
> Does this backend bring any benefits compared with gcc? E.g. will it help 
> gain support for other languages, like rust?

Yes, my primary goal was to be able to use Rust on m68k. I have already
started on the Rust part [1]. And now I need an m68k expert to help 
with the ABI part [2].

> Do you know if anyone has run the LLVM unit tests on Motorola silicon?

Not that I know of. I have successfully built LLVM natively on qemu-m68k, but
clang currently doesn't work properly [3]. I have not looked into details yet
why that doesn't work.

Adrian

> [1] https://github.com/glaubitz/rust/tree/m68k-linux
> [2] https://github.com/glaubitz/rust/blob/m68k-linux/src/librustc_target/abi/call/m68k.rs
> [3] https://github.com/M680x0/M680x0-mono-repo/issues/10

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

end of thread, other threads:[~2020-06-24  7:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 20:12 LLVM for m68k completed (but not merged) John Paul Adrian Glaubitz
2020-06-23 15:34 ` John Paul Adrian Glaubitz
2020-06-24  1:07   ` Finn Thain
2020-06-24  7:42     ` John Paul Adrian Glaubitz

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 NNTP newsgroup(s).