Repository navigation
refactor: move C/C++ code into sgx/ - #1054
Merged
mbrandenburger merged 3 commits intoNov 5, 2026
Merged
Conversation
mbrandenburger
force-pushed
the
build/sgx-subtree
branch
from
November 4, 2026 12:14
d8a79fe to
dd6d4f7
Compare
mbrandenburger
marked this pull request as ready for review
November 4, 2026 19:42
mbrandenburger
force-pushed
the
build/sgx-subtree
branch
from
November 4, 2026 22:12
e0269e3 to
4d73c94
Compare
munapower
approved these changes
Nov 5, 2026
Moves only, no content changes apart from the submodule path, which git updates: the C/C++ code (common/, ecc_enclave/, cmake/), the C++ samples and irb's chaincode, the shell integration suites, the cgo PDO verifier and the real enclave go to sgx/. The tree does not build at this commit; paths are fixed in the next two commits. Kept separate so git log --follow works and the moves can be reviewed on their own. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
The real (cgo) enclave now lives in sgx/ecc/enclave, the mock stays in ecc/chaincode/enclave. ecc picks one through newEnclave(), in two tagged files (fpc_cgo / !fpc_cgo). This is the only code change of the move. ecc/Makefile now builds the ecc package (go build -o ecc .) instead of main.go alone: naming a file makes go build only that file, so it would skip the two tagged files and newEnclave would be undefined. The moved cgo packages (sgx/ecc/enclave, sgx/attestation/epid/pdo) get their #cgo paths into sgx/common; ercc and the attestation-api test app import the PDO verifier from its new path. shim.go's include, which on main pointed at a non-existent ecc/common, is now correct as it stands. scripts/check-ecc-enclave.sh checks which enclave ecc uses with and without fpc_cgo, that ecc/Makefile builds the package, and in the dev container that ecc links libsgxcc. Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
The paths that point into the moved code:
- the top-level Makefile builds sgx/common, sgx/ecc_enclave,
sgx/samples and sgx/integration in the same order as before the move;
new sgx/samples/Makefile and sgx/integration/Makefile, integration/
keeps only the FPC-go suites
- TOP in every moved Makefile, the $ENV{FPC_PATH} paths in CMake and
scripts, #cgo paths (internal/crypto/crypto_pdo.go stays in place)
- the moved shell suites are one level deeper; their config, chaincode
and client SDK utils paths, also where Go builds them with
filepath.Join and imports the utils package
- the committed symlinks (ecc-enclave-include/lib, integration/config/ias)
- ecc, Dockerfiles, .dockerignore, .gitignore, the external builder,
irb (its chaincode moved, its Go app and protos did not)
- the peer's fpc-c external builder path in sgx/integration/config/core.yaml
- check-fpc-cgo.sh, the proto comments and the docs
Small changes made while touching these files: samples/chaincode/Makefile
drops its now redundant SUB_DIRS/TEST_DIRS, and two crashtest build files
get the SPDX header the license check asks for.
The old paths are kept where they are not paths: the ecc_enclave
component and logger name, make target names, and the substring
excludes of the linter and license scripts, which still match.
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
mbrandenburger
force-pushed
the
build/sgx-subtree
branch
from
November 5, 2026 16:39
4d73c94 to
287fd1c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Since #1048 the C/C++ side is opt-in (
FPC_CGO=1), but its code was spread across the tree:common/,ecc_enclave/,cmake/, the cgo files inecc/andinternal/, the C++ samples, irb's chaincode and the shell integration suites. This PR moves all of it under one directory,sgx/, so the code that needs the SGX toolchain is in one place. No behavior changes.common/(incl. thecommon/crypto/pdosubmodule)sgx/common/ecc_enclave/sgx/ecc_enclave/cmake/sgx/cmake/samples/chaincode/{auction,echo,kv-test}/sgx/samples/chaincode/…samples/demos/irb/chaincode/sgx/samples/demos/irb/chaincode/(irb's Go app and protos stay)integration/*_test.sh,integration/{config,crashtest,client_sdk}/sgx/integration/…(integration/go_chaincode/stays)internal/attestation/epid/pdo/sgx/attestation/epid/pdo/ecc/chaincode/enclave/{enclave,shim,logging_cgo,logging_go}.go)sgx/ecc/enclave/(the mock stays)What stays:
ecc/,fabric/,protos/, irb's Go app,integration/go_chaincode/, and the PDO crypto ininternal/crypto/(its test is coupled to the shared crypto test table; only its#cgopaths change).Which issue(s) this PR fixes:
Fixes #1041. Part of #1044.
Special notes for your reviewer:
Three commits, best reviewed one by one (please rebase-merge, so
git log --followworks):git mv, 167 files renamed with identical content, and the.gitmodulespath that git updates. The tree does not build at this commit.ecc/main.gopicks the enclave throughnewEnclave()in two tagged files,ecc/enclave_cgo.go(fpc_cgo, the real one fromsgx/ecc/enclave) andecc/enclave_mock.go(!fpc_cgo, the mock).scripts/check-ecc-enclave.shchecks which oneeccuses with and without the tag.sgx/...in place of each moved part), CMake and script$ENV{FPC_PATH}paths,#cgopaths, the moved shell suites (one level deeper), Gofilepath.Joinpaths and the movedutilsimport, the committed symlinks, Dockerfiles, irb, and docs.How I checked the move is complete:
samples/chaincode/echodoesn't matchecho-go), the Gofilepath.Joinsegment form, Go imports of moved packages, and dangling symlinks. The remaining hits are not paths: theecc_enclavecomponent and logger name, make target names, and the linter and license excludes, which match as substrings and still work.git clone --recursivepopulatessgx/common/crypto/pdoand builds.go build/vet/test ./...,make build test checks, and thecheck-*scripts pass.Left as they were, because changing them would change behavior:
ecc/Makefile'scleanremovesenclave/ecc-enclave-{lib,include}, a path that never existed (the links are committed, so actually removing them would leave the tree dirty);sgx/ecc_enclave/CMakeLists.txtsets an unusedDEPLOY_DIR.Does this PR introduce a user-facing changes and/or breaks backward compatability?:
Yes, paths change. For out-of-tree C++ chaincode and scripts:
$FPC_PATH/cmake/$FPC_PATH/sgx/cmake/$FPC_PATH/ecc_enclave/(e.g.enclave/CMakeLists-common-app-enclave.txt)$FPC_PATH/sgx/ecc_enclave/$FPC_PATH/common/$FPC_PATH/sgx/common/$FPC_PATH/integration/config/$FPC_PATH/sgx/integration/config/$FPC_PATH/samples/chaincode/{auction,echo,kv-test}/$FPC_PATH/sgx/samples/chaincode/…Go:
internal/attestation/epid/pdo(internal, so only used in this repo) is nowsgx/attestation/epid/pdo, and the real enclave packageecc/chaincode/enclaveis nowsgx/ecc/enclave(ecc/chaincode/enclavekeeps the mock). Existing build directories (_build) under the old paths have to be rebuilt.