English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. C/C++ (https://eab.abime.net/forumdisplay.php?f=118)
-   -   GCC 6.2 toolchain for AmigaOS 3 (https://eab.abime.net/showthread.php?t=85474)

Olaf Barthel 06 March 2024 12:47

Quote:

Originally Posted by Mafi (Post 1672714)

...

My biggest problem is that Clang (pretty much used by all language servers like clangd and ccls) chokes on a lot of the NDK includes (mainly protos and any declarations using 68k registers. Basically means auto-complete etc. doesn't work, or partially works.

Which version/release of the AmigaOS 3.2 NDK are you currently using, exactly? The most recent release is still AmigaDOS 3.2 NDK R4, with R5 still being in the works.

R5 features further interface header file changes which render them more robust if the compiler environment claims to be the GNU 'C' compiler, but is really clang. The interface header files assumed that if gcc was showing its hand, it was a native or cross compiler targeted for AmigaOS 68k. With the current work-in-progress, you can actually use these header files directly with VSCode, for example, and no local changes required to even narrowly avoid tripping the code completion up. One of these days we might even had helpful code comments in the <clib/#?_protos.h> header files :)

R4 was still focused on getting the gcc 68k and vbcc interface header files into shape. That there was more trouble on the horizon with cross-compilation, etc. had yet to be discovered and addressed :shocked

Mafi 06 March 2024 13:07

Quote:

Originally Posted by Olaf Barthel (Post 1672753)
Which version/release of the AmigaOS 3.2 NDK are you currently using, exactly? The most recent release is still AmigaDOS 3.2 NDK R4, with R5 still being in the works.

R5 features further interface header file changes which render them more robust if the compiler environment claims to be the GNU 'C' compiler, but is really clang. The interface header files assumed that if gcc was showing its hand, it was a native or cross compiler targeted for AmigaOS 68k. With the current work-in-progress, you can actually use these header files directly with VSCode, for example, and no local changes required to even narrowly avoid tripping the code completion up. One of these days we might even had helpful code comments in the <clib/#?_protos.h> header files :)

R4 was still focused on getting the gcc 68k and vbcc interface header files into shape. That there was more trouble on the horizon with cross-compilation, etc. had yet to be discovered and addressed :shocked

TBH, I'm not sure... at least as it relates to the cross-compilation toolchain. I run Bebbo's install and it downloads NDK automatically; I just checked the header files and they appear to be dated mid-2021?!). On my real-Amiga I use R4.

Now I'm eagerly awaiting R5! :) My goal is to use (neo)vim with something like YCM as the auto-completion plugin. If I can get that going with 3.2 NDK R5 I'll be super happy.

Thanks for the update. :)

-M

thyslo 06 March 2024 13:36

Thanks for showing the CMakeLists file, I'll have a look at it.

For autocomplete when programming in VSCode I have a workaround. In vscode setting file c_cpp_properties.json I define __clang__

Code:

            "defines": [
                "__clang__"
            ],

And in the .c/.cpp files I include the library proto headers like:
Code:


#ifdef __clang__
  #include <clib/alib_protos.h>
  #include <clib/exec_protos.h>
  #include <clib/dos_protos.h>
  #include <clib/intuition_protos.h>
#else
  #include <proto/alib.h>
  #include <proto/dos.h>
  #include <proto/exec.h>
  #include <proto/intuition.h>
#endif

With this, autocomplete works quite well here.

Olaf Barthel 06 March 2024 14:06

Quote:

Originally Posted by Mafi (Post 1672754)
TBH, I'm not sure... at least as it relates to the cross-compilation toolchain. I run Bebbo's install and it downloads NDK automatically; I just checked the header files and they appear to be dated mid-2021?!).

That likely makes them part of AmigaOS NDK 3.2 R3. The R4 header files should be dated early February 2022 (and we didn't manage to release R5 in 2023).

Quote:

On my real-Amiga I use R4.
:great

Quote:

Now I'm eagerly awaiting R5! :) My goal is to use (neo)vim with something like YCM as the auto-completion plugin. If I can get that going with 3.2 NDK R5 I'll be super happy.

Thanks for the update. :)

-M
Happy to whet your appetite ;) It's been taking longer than expected to get the next release "into orbit" because of the bug fixes applied to header files and much expanded documentation for the dos.library in the form of the now largest Autodoc file ever. Questions will be answered which managed to elude explanation and context for more than 30 years.

Just this month we kindly received fixes for the assembly language header files found in the "datatypes" drawer: they had been broken since at least 1993. The dos.library 'C' header files have been thoroughly reworked for perhaps the first time since 1989.

There's plenty to look forward to and, hopefully, make it easier to unlock what was previously hard to find in the documentation, if at all.

Mafi 07 March 2024 05:14

Thanks Thyslo! I think there are other non-proto files that use __stdargs and ASM registers that clang refuses to work with. However, this might be a good stop-gap to eliminate a good chunk of errors!

-M

Mafi 07 March 2024 12:16

Ok, I replaced the NDK version installed as part of the toolchain with R4 and clang complains much less, like much less. So for now I can probably live with this until R5 is made available! Thanks again.

-M

Olaf Barthel 07 March 2024 17:33

Quote:

Originally Posted by Mafi (Post 1672925)
Ok, I replaced the NDK version installed as part of the toolchain with R4 and clang complains much less, like much less. So for now I can probably live with this until R5 is made available! Thanks again.

-M

Hey, progress after all :)

Maybe there is a future for the NDK 3.2 R4 header files in the gcc distribution after all.

alkis 07 March 2024 21:03

Quote:

Originally Posted by Mafi (Post 1672925)
Ok, I replaced the NDK version installed as part of the toolchain with R4 and clang complains much less, like much less. So for now I can probably live with this until R5 is made available! Thanks again.

-M

For emacs + eglot I had to do it like that
Code:

#ifdef __clang__
#define __stdargs
#define __aligned
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#else
#include <proto/dos.h>
#include <proto/exec.h>
#endif

With those two defines I think I stopped getting errors.

Olaf Barthel 08 March 2024 09:33

Quote:

Originally Posted by alkis (Post 1672998)
For emacs + eglot I had to do it like that
Code:

#ifdef __clang__
#define __stdargs
#define __aligned
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#else
#include <proto/dos.h>
#include <proto/exec.h>
#endif

With those two defines I think I stopped getting errors.

Careful about that __aligned keyword. The code which needs it may have to be rewritten. Accidentally removing it through the preprocessor can have unforseen and really annoying consequences. The stack may get trashed, which is always hard to detect as the cause of unexpected trouble.

alkis 08 March 2024 10:48

Quote:

Originally Posted by Olaf Barthel (Post 1673049)
Careful about that __aligned keyword. The code which needs it may have to be rewritten. Accidentally removing it through the preprocessor can have unforseen and really annoying consequences. The stack may get trashed, which is always hard to detect as the cause of unexpected trouble.

No. See this is only for __clang__ (which emacs' eglot uses). When you do the actual compile with gcc, __clang__ is not defined.

jotd 01 May 2024 17:25

I have a question: is there an equivalent of __LINE__ for current asm line number?

I'd like to set a register like

Code:

    move.l  #__LINE__,d0
in case of an error for instance

BTW I had a lot of issues with PC-relative LEA which weren't in the same unit. I got a warning when linking (using long... for ...) but the address was still PC relative and it read at the wrong location.

Great assembler no matter what. Using it for 15+ projects now.

paraj 01 May 2024 17:54

Quote:

Originally Posted by jotd (Post 1682233)
I have a question: is there an equivalent of __LINE__ for current asm line number?

I'd like to set a register like

Code:

    move.l  #__LINE__,d0
in case of an error for instance

BTW I had a lot of issues with PC-relative LEA which weren't in the same unit. I got a warning when linking (using long... for ...) but the address was still PC relative and it read at the wrong location.

Great assembler no matter what. Using it for 15+ projects now.


The exact snippet you wrote does work as intended if you enable preprocessing and use the gcc frontend (i.e. not as, otherwise preprocess manually).


This happens automatically if the input file is called ".S" rather than ".s" (yes, bad convention on case-insensitive file systems). Alternatively you can add "-x assembler-with-cpp" on the command line.


Code:

/tmp$ cat test.S && m68k-amigaos-gcc -c test.S && m68k-amigaos-objdump -D test.o
        nop
        move.l #__LINE__,d0


test.o:    file format amiga


Disassembly of section .text:

00000000  .text:
  0:  4e71            nop
  2:  7002            moveq #2,d0


jotd 01 May 2024 18:42

that's good and it works. But not in macros (.macro) where it's very useful. Maybe with #define... but multi-line defines with "" don't seem to work either. Oh damn.

paraj 01 May 2024 19:12

Quote:

Originally Posted by jotd (Post 1682244)
that's good and it works. But not in macros (.macro) where it's very useful. Maybe with #define... but multi-line defines with "" don't seem to work either. Oh damn.

Ahh, new requirements :)


You can probably hack around it with another level of indirection, like:
Code:

// before
  .macro m x,y
  //..

  .endm

  m x,y
// after
  .macro _m x,y,line
  move.l #\line,d0

  //..

  .endm


#define m(x,y) _m x,y,__LINE__

  m(x,y)

Not tested, but you get the idea... Maybe there is some GCC magic to get line in another way in .macro, but I doubt it..

jotd 01 May 2024 19:40

yes, with double macro layer it probably works. Well now it's so nonstandard that I don't want to go that route!

paraj 01 May 2024 19:56

Quote:

Originally Posted by jotd (Post 1682258)
yes, with double macro layer it probably works. Well now it's so nonstandard that I don't want to go that route!

Understandable. I'm not a GNU as wizard (and this is maybe venturing a bit OT), but perhaps you can use \@ to accomplish what you want:
Code:

        .macro A
        move.l  #100+\@,d0
        .endm
        .macro B
        move.l  #200+\@,d0
        .endm

        A
        A
        B
        A


Much less convenient than __LINE__ and care needs be taken for separate compilation units, but might do what you need in this case...


All times are GMT +2. The time now is 13:03.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.13736 seconds with 11 queries