English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 19 May 2017, 14:09   #1
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
compile problems (vbcc)

Three problems occured to me while compiling some project :
- There is no strdup function. It's not in string.h as should be, and no .lib contains it.
- Assembler says unknown mnemonic for <inline> and <einline>. New to 0.9f ; version 0.905 did not have this issue.
- Linker complains about missing _nearbyintf symbol. It's available in some fpu libs (like m040.lib), but that does not look like a proper way for building a nofpu version...
meynaf is offline  
Old 19 May 2017, 14:42   #2
ajk
Registered User
 
ajk's Avatar
 
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,341
I don't think strdup() is a standard function. POSIX maybe?
ajk is offline  
Old 19 May 2017, 14:56   #3
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
Posix
ross is offline  
Old 19 May 2017, 15:20   #4
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
So only thing i can do is to find some C implementation of it and add that to the program ?
meynaf is offline  
Old 19 May 2017, 15:29   #5
ajk
Registered User
 
ajk's Avatar
 
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,341
That's probably easiest. It should only be a few lines of code. Someone on StackOverflow suggest this:

Code:
char *strdup (const char *s) {
    char *d = malloc (strlen (s) + 1);   // Allocate memory
    if (d != NULL) strcpy (d,s);         // Copy string if okay
    return d;                            // Return new memory
}
ajk is offline  
Old 19 May 2017, 15:52   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Ok, done. Now what for the next two problems ?
meynaf is offline  
Old 19 May 2017, 17:23   #7
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by meynaf View Post
Three problems occured to me while compiling some project :
- There is no strdup function. It's not in string.h as should be, and no .lib contains it.
The strdup is also in Frank's PosixLib.

http://aminet.net/package/dev/c/vbcc_PosixLib

Quote:
Originally Posted by meynaf View Post
- Assembler says unknown mnemonic for <inline> and <einline>. New to 0.9f ; version 0.905 did not have this issue.
Strange. I haven't downloaded and installed the new version yet but I thought Frank was going to use the new header files with inline/einline for assembler inlines (in string.h, stdlib.h, etc.). We discussed having them work in -phxass mode of vasm (was default for vbcc) as that would ease the transition to using regular vasm mode but he may have removed this support. I guess I need to install and see.

Quote:
Originally Posted by meynaf View Post
- Linker complains about missing _nearbyintf symbol. It's available in some fpu libs (like m040.lib), but that does not look like a proper way for building a nofpu version...
Which floating point math lib did you compile/link with? The behavior should be the same for -lm881, -lm040 and -lm060. The -lmieee option uses the C= libraries and is limited by the support they give. The nearbyintf() function/macro uses "fint fp0" using the current rounding mode but the C= ieee libraries have no concept of a rounding mode. Frank was looking into adding a different but better soft floating point library at one point. I also considered creating an Amiga c99fps.library and c99fpd.library as more modern ieee library replacements at one time. The current fp support provides what most people would use as is and there might not even be enough users of a better soft float option to properly test and debug the code.
matthey is offline  
Old 19 May 2017, 17:52   #8
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by matthey View Post
Which floating point math lib did you compile/link with? The behavior should be the same for -lm881, -lm040 and -lm060. The -lmieee option uses the C= libraries and is limited by the support they give. The nearbyintf() function/macro uses "fint fp0" using the current rounding mode but the C= ieee libraries have no concept of a rounding mode. Frank was looking into adding a different but better soft floating point library at one point. I also considered creating an Amiga c99fps.library and c99fpd.library as more modern ieee library replacements at one time. The current fp support provides what most people would use as is and there might not even be enough users of a better soft float option to properly test and debug the code.
The whole story is : currently trying to compile something for making it work before possible asm conversion/optimization. Said otherwise, it's not my own code to start with so i can't really change its structure (at least not before having made it work).

As it appears to rely heavily on C99 it seems only VBCC will do it - GCC does not work on my setup and is asm unfriendly anyway (no option to output proper amiga asm source).

I wanted to use -lmieee only.
Then the linker complained about nearbyintf (without that function being called explicitly anywhere).
I added -lm040 as the function is there. Noticed -lmieee was still needed so both got linked in.
Then it could finally be built. However it now needs fpu.
I started uae in 040 mode to test results and found out the program does not work anymore (same source code works fine with VS2015).
Currently trying to debug the bloody thing to discover what went wrong (no crash, just bogus data output).

If you tell me i can't have proper nearbyintf implementation without fpu then so be it - better than not compiling at all.
meynaf is offline  
Old 19 May 2017, 18:49   #9
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by meynaf View Post
I wanted to use -lmieee only.
Then the linker complained about nearbyintf (without that function being called explicitly anywhere).
I added -lm040 as the function is there. Noticed -lmieee was still needed so both got linked in.
Then it could finally be built. However it now needs fpu.
I started uae in 040 mode to test results and found out the program does not work anymore (same source code works fine with VS2015).
Currently trying to debug the bloody thing to discover what went wrong (no crash, just bogus data output).
Be careful *not* to...

o link code compiled with different math libs (e.g. -lmieee and -lm040)
o specify -fpu=68xxx with -lmieee

There probably should be more tests and error messages for these conditions as the result can compile fine but crash.

Quote:
Originally Posted by meynaf View Post
If you tell me i can't have proper nearbyintf implementation without fpu then so be it - better than not compiling at all.
As far as I know, nearbyintf() can not be supported as is by the Amiga ieee libraries. It should be possible for a soft float implementation to support nearbyintf() but I do not believe there is any vbcc support for the 68k AmigaOS target at this time.
matthey is offline  
Old 19 May 2017, 18:58   #10
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by matthey View Post
Be careful *not* to...

o link code compiled with different math libs (e.g. -lmieee and -lm040)
Well, this is what i did because else it refused to link.

Errors should appear if the same function name occurs several times, shouldn't they ?


Quote:
Originally Posted by matthey View Post
o specify -fpu=68xxx with -lmieee
I didn't specify -fpu...
So it's needed even for 040 ?


Quote:
Originally Posted by matthey View Post
There probably should be more tests and error messages for these conditions as the result can compile fine but crash.
No crash here, just lrintf not working - always returning 0.


Quote:
Originally Posted by matthey View Post
As far as I know, nearbyintf() can not be supported as is by the Amiga ieee libraries. It should be possible for a soft float implementation to support nearbyintf() but I do not believe there is any vbcc support for the 68k AmigaOS target at this time.
Isn't this some kind of (int)(floatval+0.5f) or something like that ?

I replaced it with normal cast and it now works. I don't really need "proper" rounding anyway.
meynaf is offline  
Old 19 May 2017, 20:04   #11
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
Quote:
Originally Posted by meynaf View Post
Well, this is what i did because else it refused to link.

Errors should appear if the same function name occurs several times, shouldn't they ?
Multiple function calls are fine. The correct support code just has to be found.

Quote:
Originally Posted by meynaf View Post
I didn't specify -fpu...
So it's needed even for 040 ?
In my experience, -fpu=68040 and -lm040 should be added together.

Quote:
Originally Posted by meynaf View Post
No crash here, just lrintf not working - always returning 0.
The program is still broken and I believe crashes are possible with what you did.

Quote:
Originally Posted by meynaf View Post
Isn't this some kind of (int)(floatval+0.5f) or something like that ?
No, the rounding of FINT is variable depending on the C99 fenv (floating point environment) with current rounding settings in the 68k FPU FPCR. If the rounding is known at compile time then a different function or casting should be used as it may be faster.

Quote:
Originally Posted by meynaf View Post
I replaced it with normal cast and it now works. I don't really need "proper" rounding anyway.
I believe C casting defaults to round toward zero which would be like the FINTRZ instruction.

Last edited by matthey; 19 May 2017 at 20:46.
matthey is offline  
Old 19 May 2017, 20:33   #12
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by matthey View Post
Multiple function calls is fine. The correct support code just has to be found.
Yes but it was about multiple support code for the same function, i.e. same feature linked from several libs.


Quote:
Originally Posted by matthey View Post
The program is still broken and I believe crashes are possible with what you did.
A crash would probably have been easier to debug...
meynaf is offline  
Old 20 May 2017, 19:01   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by meynaf View Post
- Assembler says unknown mnemonic for <inline> and <einline>. New to 0.9f ; version 0.905 did not have this issue.
Works for me. Check your vasm version. You need at least vasm 1.7f to make these directives work (vbcc 0.9f includes vasm 1.8).

Quote:
Originally Posted by meynaf View Post
No crash here, just lrintf not working - always returning 0.
As matthey already mentioned the implementation of nearbyintf(), which is called for lrintf(), is quite simple and only works for floats between -2147483648 and 2147483647.

Matthey implemented many new C99 math functions and improved present ones, but unfortunately for FPU only (I certainly won't blame him). So I tried to implement a few new C99 functions for softfloat (mieee.lib), but I didn't find the time for all. You can blame me!
phx is offline  
Old 20 May 2017, 19:10   #14
plasmab
Banned
 
plasmab's Avatar
 
Join Date: Sep 2016
Location: UK
Posts: 2,917
I love vbcc and vasm. But compiling a hello world style C file seems to eat my 4mb of ram up quickly. Any way to make it use temp disk space rather than ram: for temp files?
plasmab is offline  
Old 20 May 2017, 20:15   #15
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by phx View Post
Works for me. Check your vasm version. You need at least vasm 1.7f to make these directives work (vbcc 0.9f includes vasm 1.8).
I used the vbcc 0.9f archive "as is", without touching vasm.


Quote:
Originally Posted by phx View Post
As matthey already mentioned the implementation of nearbyintf(), which is called for lrintf(), is quite simple and only works for floats between -2147483648 and 2147483647.

Matthey implemented many new C99 math functions and improved present ones, but unfortunately for FPU only (I certainly won't blame him). So I tried to implement a few new C99 functions for softfloat (mieee.lib), but I didn't find the time for all. You can blame me!
Too late to blame you, I did otherwise
meynaf is offline  
Old 21 May 2017, 21:12   #16
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by plasmab View Post
Any way to make it use temp disk space rather than ram: for temp files?
Try to assign T: to a place on your disk.

Quote:
Originally Posted by meynaf View Post
I used the vbcc 0.9f archive "as is", without touching vasm.
Any old vasm version somewhere in your path? When the problem persists, please send me something to reproduce it. (Although I'm currently on holiday in Greece, so I probably can't tackle the problem in the next 6 days).
phx is offline  
Old 22 May 2017, 07:48   #17
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
Quote:
Originally Posted by phx View Post
Any old vasm version somewhere in your path? When the problem persists, please send me something to reproduce it. (Although I'm currently on holiday in Greece, so I probably can't tackle the problem in the next 6 days).
Somewhere on my normal path no, but it's possible some assign leading to 1.7e was still there. If this was the case then it was using the old compiler as well.
meynaf is offline  
Old 22 May 2017, 11:42   #18
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
I have found the sources of vbcc itself but not the sources of the .lib. Where can i find sources for all these .lib (amigaos target) ?
A .s (including compiler output) is more manageable for me than a .lib.
meynaf is offline  
Old 22 May 2017, 16:22   #19
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
The linker libraries are the only parts which are not open source. Volker Barthelmann has no intention to change that, for various reasons.

If you have a specific problem or want to work on parts of the library source, then contact me privately. Maybe we can find a solution.
phx is offline  
Old 22 May 2017, 18:33   #20
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,766
Quote:
Originally Posted by meynaf View Post
while compiling some project
Can I ask which one so I can have a look?
Thorham is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with compile JimDrew Coders. Language 23 30 October 2014 22:42
Compile problems with VBCC Yesideez Coders. C/C++ 9 18 October 2014 23:38
How compile WinUAE... WCoder support.WinUAE 57 17 April 2014 17:42
GFA compile xc8 Coders. General 31 19 May 2009 18:21
Compile WinUAE ????? Myriel support.WinUAE 14 10 January 2004 17:06

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11086 seconds with 13 queries