Summary
Unable to compile a mathh gama instruction at or above optimize-level 3
Metadata
- Id: a53d06e94e260378cc3dacd192b4d5ce453c8366
- Trac id: 1340
- Type: defect
- Reporter: rca
- Owner:
- Cc:
- Status: new
- Component: unknown
- Estimated difficulty: medium
- Resolution:
- Priority: minor
- Milestone: someday
- Version: 4.11.0
- Changetime: 2021-04-12 13:40:17 UTC
- Created: 2017-01-16 02:02:34 UTC
- Keywords:
Description
Compiling the following code at or above optimize-level 3 results in an error.
(define (factorial x)
(gamma (+ 1 x)) )
(factorial 9)}}}
csc -optimize-level 3 test.scm
test.c:213:4: warning: implicit declaration of function
'stub177' is invalid in C99
[-Wimplicit-function-declaration]
t6=stub177(t4,t5);
^
1 warning generated.
Changes and comments
[2017-01-16 03:42:37 UTC] rca wrote:
Did some checking and it impacts more than just gamma… nothing in mathh seems to compile at level 3.
[2017-01-16 11:09:32 UTC] kooda wrote:
The undefined C functions seem to be part of the mathh.c file when compiling mathh.scm, but for some reason these are declared static there, thus making it impossible to use them while inlining.
For example, the mathh.c file contains the mentioned stub177 function:
C_regparm static C_word C_fcall stub177(C_word C_buf,C_word C_a0){
C_word C_r=C_SCHEME_UNDEFINED,*C_a=(C_word*)C_buf;
double t0=(double )C_c_double(C_a0);
C_r=C_flonum(&C_a,tgamma(t0));
return C_r;}
[2017-01-16 11:09:32 UTC] kooda wrote:
1484561394741085
[2017-01-31 19:36:24 UTC] rca wrote:
Error persists with version 4.12rc1.
[2017-03-03 12:27:51 UTC] LemonBoy wrote:
This happens because all the functions are defined using `foreign-lambda` which in turn does nothing but generate a stub (see `create-foreign-stub`) that serves as a trampoline for calling the real C function: the stub that gets generated in that phase is the ones you're seeing in the `.inline` file. But there's more: all the stub does is preparing the environment and then it just calls another stub which in turn calls the C function and this part is missing from the inline file as it's generated much later (in `c-backend.scm` `generate-foreign-stubs`, the stub name is the variable named `f-id` in `create-foreign-stub`).
[2017-08-25 15:26:23 UTC] sjamaan set difficulty to medium
[2017-08-25 15:26:23 UTC] sjamaan changed milestone from someday to 4.13.0
[2017-08-25 15:26:23 UTC] sjamaan wrote:
Is this fixable?
[2017-09-16 16:28:49 UTC] kon wrote:
rmvd gen of mathh.inline in 3.2.2 so cannot generate error.
[2017-10-19 12:08:55 UTC] sjamaan wrote:
This is not trivially fixed, except by not generating inline files (as Kon has done). I think a proper fix will have to wait for 5.1 or later.
[2017-10-19 12:08:55 UTC] sjamaan changed milestone from 4.13.0 to 5.1
[2019-04-07 12:23:24 UTC] sjamaan changed milestone from 5.1 to 5.2
[2019-04-07 12:23:24 UTC] sjamaan wrote:
Getting ready for 5.1, moving tickets which won't make it in to 5.2.