[X86][lvm] lld + fsplit-stack+ -fpatchable-function-entry error

I’m getting an error with a lld link, ld is ok.

clang -fuse-ld=lld  -fsplit-stack -fpatchable-function-entry=1 t.c 
#include <stdio.h>

int main()
{
  int a;
  scanf("%d", &a);
  printf("%d\n", a);
}
ld.lld: error: /tmp/example-e14cd8.o:(.text): main (with -fsplit-stack) calls __isoc99_scanf (without -fsplit-stack), but couldn't adjust its prologue
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is -fsplit-stack and -fpatchable-function-entry=1 incompatibility?

-fsplit-stack and -fpatchable-function-entry=1 are incompatible. The split stack design requires linkers to rewrite the function prologue for a function call from a split-stack relocatable object file to a non-split-stack relocatable object file. The prologue code is hardcoded, incompatible if you tweak it by adding NOP instructions.

It seems that people used split stacks have moved on to newer technology that does not require linker rewriting, and the split stack linker support is out-fashioned. There is nearly no value tweaking the linkers to support more configurations.

1 Like

Thank you for taking the time to answer. Your answer help me a lot and answered my doubts. THS!

1 Like