28 lines
1.2 KiB
C
28 lines
1.2 KiB
C
// ltoProbe.c - Phase 5.2 ThinLTO smoke probe.
|
|
// Calls a helper compiled in a SEPARATE TU (ltoProbeHelper.c) via the
|
|
// scripts/ltoLink.sh driver. The helper returns a constant; under LTO
|
|
// the value gets constant-folded into main and printf sees the literal.
|
|
// In the non-LTO build, the call survives as a real jsl long.
|
|
//
|
|
// Build commands (LTO):
|
|
// CC=tools/llvm-mos-build/bin/clang
|
|
// $CC --target=w65816 -I runtime/include -O2 -ffunction-sections \
|
|
// -emit-llvm -c demos/ltoProbe.c -o /tmp/ltoProbe.bc
|
|
// $CC --target=w65816 -I runtime/include -O2 -ffunction-sections \
|
|
// -emit-llvm -c demos/ltoProbeHelper.c -o /tmp/ltoProbeHelper.bc
|
|
// bash scripts/ltoLink.sh -o /tmp/ltoProbeMerged.o \
|
|
// /tmp/ltoProbe.bc /tmp/ltoProbeHelper.bc
|
|
// ... then link /tmp/ltoProbeMerged.o with crt0Gno + libcGno + ...
|
|
// via tools/link816, wrap with tools/omfEmit, run under runInGno.sh.
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
extern int computeMagic(void);
|
|
|
|
int main(int argc, char **argv) {
|
|
int m = computeMagic();
|
|
printf("magic=0x%x\n", m);
|
|
*(volatile uint16_t *)0x025000UL = (uint16_t)m;
|
|
for (volatile unsigned long i = 0; i < 100000UL; i++) {}
|
|
return 0;
|
|
}
|