Opened 3 years ago

Last modified 3 months 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: 5.2
Component: unknown Version: 4.11.0
Keywords: Cc:
Estimated difficulty: medium


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


1 warning generated.

Change History (8)

comment:1 Changed 3 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 3 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 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);
return C_r;}
Last edited 3 years ago by kooda (previous) (diff)

comment:3 Changed 2 years ago by rca

Error persists with version 4.12rc1.

comment:4 Changed 2 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 2 years ago by sjamaan

  • Estimated difficulty set to medium
  • Milestone changed from someday to 4.13.0

Is this fixable?

comment:6 Changed 22 months ago by kon

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

comment:7 Changed 21 months ago by sjamaan

  • Milestone changed from 4.13.0 to 5.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 3 months ago by sjamaan

  • Milestone changed from 5.1 to 5.2

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

Note: See TracTickets for help on using tickets.