Opened 8 years ago

Last modified 4 years ago

#1340 new defect

Unable to compile a mathh gama instruction at or above optimize-level 3

Reported by: rca Owned by:
Priority: minor Milestone: someday
Component: unknown Version: 4.11.0
Keywords: Cc:
Estimated difficulty: medium

Description

Compiling the following code at or above optimize-level 3 results in an error.

{{{(use mathh)

(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.

Change History (10)

comment:1 Changed 8 years ago by rca

Did some checking and it impacts more than just gamma… nothing in mathh seems to
compile at level 3.

comment:2 Changed 8 years ago by Kooda

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 why 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;}
Version 0, edited 8 years ago by Kooda (next)

comment:3 Changed 8 years ago by rca

Error persists with version 4.12rc1.

comment:4 Changed 8 years ago by LemonBoy

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).

comment:5 Changed 7 years ago by sjamaan

Estimated difficulty: medium
Milestone: someday4.13.0

Is this fixable?

comment:6 Changed 7 years ago by Kon Lovett

rmvd gen of mathh.inline in 3.2.2 so cannot generate error.

comment:7 Changed 7 years ago by sjamaan

Milestone: 4.13.05.1

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.

comment:8 Changed 6 years ago by sjamaan

Milestone: 5.15.2

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

comment:9 Changed 5 years ago by felix winkelmann

Milestone: 5.25.3

comment:10 Changed 4 years ago by sjamaan

Milestone: 5.3someday
Note: See TracTickets for help on using tickets.