STG/CMM questions

Daneel Yaitskov dyaitskov at gmail.com
Thu May 28 21:18:20 UTC 2020


Hi,

There are 2 questions:

1. How to decipher myThreadId implementation in STG?

What is the principle behind STG version?
Is it matching first field from TSO by type?
"id" is not mentioned anyhow and there is no offset to id field.
The whole TSO struct is just mentioned.

emitAssign and CmmLocal are used everywhere,
so they don't express logic particular to myThreadId function.

was:
    return tso->id;

now:
   currentTSOExpr = CmmReg currentTSOReg
   MyThreadIdOp -> \[] -> opAllDone $ \[res] -> do
     emitAssign (CmmLocal res) currentTSOExpr



2. Cmm macro for new TSO field is not found.

I added to deriveConstants/Main.hs:
          ,closureField  C    "StgTSO"      "trace_id"
TSO.h:
typedef struct StgTSO_ {
          ...
          StgClosure* trace_id;
PrimsOps.cmm:
    gcptr p;
    p =  StgTSO_trace_id(CurrentTSO);

Linking error happens after make clean && ./boot && ./configure && make -j8
so I guess macros is not defined. Looks like such macros are not
written to any file
and it is hard to grep them.

collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
utils/iserv/ghc.mk:101: recipe for target
'utils/iserv/stage2/build/tmp/ghc-iserv' failed
make[1]: *** [utils/iserv/stage2/build/tmp/ghc-iserv] Error 1
/home/dan/demo/haskell/compiler/ghc/rts/dist/build/libHSrts_thr_p.a(PrimOps.thr_p_o):function
stg_getAdamTraceIdzh: error: undefined reference to 'StgTSO_trace_id'
/home/dan/demo/haskell/compiler/ghc/rts/dist/build/libHSrts_thr_p.a(PrimOps.thr_p_o):function
stg_getAdamTraceIdzh: error: undefined reference to 'n'
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
utils/iserv/ghc.mk:105: recipe for target
'utils/iserv/stage2_p/build/tmp/ghc-iserv-prof' failed
make[1]: *** [utils/iserv/stage2_p/build/tmp/ghc-iserv-prof] Error 1
Makefile:123: recipe for target 'all' failed

-- 

Best regards,
Daniil Iaitskov


More information about the ghc-devs mailing list