Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions doc/simplicity-c-code-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Updating Simplicity C code in Elements

This document describes how to update the Simplicity C code subtree in the Elements repository.

Reference: https://github.com/BlockstreamResearch/simplicity/issues/329#issuecomment-3715844042

## Simplicity

- Clone or pull the latest `master` branch of the [Simplicity](https://github.com/BlockstreamResearch/simplicity) repository.

- Split out a new subtree of the Simplicity `C` source to the `C-master` branch.

```
git subtree split -P C -b C-master
```

- Push the `C-master` branch to a public remote.

```
git push <remote> C-master
```

## Elements

- Add a reference to the above simplicity remote in your Elements repo.

```
git remote add <new-remote-name> [email protected]:<user>/simplicity.git
```

- Pull and squash the `C-master` branch subtree into the `src/simplicity` directory in Elements.

```
git subtree pull --prefix src/simplicity <new-remote-name> C-master --squash
```

- Run build and tests.

- Create a new PR to Elements.
13 changes: 9 additions & 4 deletions src/simplicity/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
OBJS := bitstream.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o elements/env.o elements/exec.o elements/ops.o elements/elementsJets.o elements/primitive.o elements/cmr.o elements/txEnv.o
CORE_OBJS := bitstream.o dag.o deserialize.o eval.o frame.o jets.o jets-secp256k1.o rsort.o sha256.o type.o typeInference.o
BITCOIN_OBJS := bitcoin/env.o bitcoin/ops.o bitcoin/bitcoinJets.o bitcoin/primitive.o bitcoin/txEnv.o
ELEMENTS_OBJS := elements/env.o elements/exec.o elements/ops.o elements/elementsJets.o elements/primitive.o elements/cmr.o elements/txEnv.o
TEST_OBJS := test.o ctx8Pruned.o ctx8Unpruned.o hashBlock.o regression4.o schnorr0.o schnorr6.o typeSkipTest.o elements/checkSigHashAllTx1.o

# From https://fastcompression.blogspot.com/2019/01/compiler-warnings.html
Expand All @@ -18,18 +20,21 @@ elements/elementsJets.o: elements/elementsJets.c
$(CC) -c $(CFLAGS) $(CWARN) -Wno-switch-enum -Wswitch $(CPPFLAGS) -o $@ $<

sha256.o: sha256.c
$(CC) -c $(CFLAGS) -msha -msse4 $(CWARN) -Wno-cast-align -Wno-sign-conversion $(CPPFLAGS) -o $@ $<
$(CC) -c $(CFLAGS) $(X86_SHANI_CXXFLAGS) $(CWARN) -Wno-cast-align -Wno-sign-conversion $(CPPFLAGS) -o $@ $<

%.o: %.c
$(CC) -c $(CFLAGS) $(CWARN) $(CPPFLAGS) -o $@ $<

libElementsSimplicity.a: $(OBJS)
libBitcoinSimplicity.a: $(CORE_OBJS) $(BITCOIN_OBJS)
ar rcs $@ $^

libElementsSimplicity.a: $(CORE_OBJS) $(ELEMENTS_OBJS)
ar rcs $@ $^

test: $(TEST_OBJS) libElementsSimplicity.a
$(CC) $^ -o $@ $(LDFLAGS)

install: libElementsSimplicity.a
install: libBitcoinSimplicity.a libElementsSimplicity.a
mkdir -p $(out)/lib
cp $^ $(out)/lib/
cp -R include $(out)/include
Expand Down
Loading