Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFFI_EXCLUDE for KMC Compilation #220

Closed
dccutrig opened this issue Jan 23, 2024 · 1 comment
Closed

CFFI_EXCLUDE for KMC Compilation #220

dccutrig opened this issue Jan 23, 2024 · 1 comment
Assignees
Labels
kmc NASA JPL KMC

Comments

@dccutrig
Copy link
Contributor

Email from Hayk, capturing here to test results:

When doing a KMC build with PR #210 we ran into some problems with the CFFI code on the KMC side. Specifically with this line: https://github.jpl.nasa.gov/ASEC/AMMOS-CryptoLib/blob/master/kmc_sdls/kmc_sdls_python/_cffi_src/tasks.py#L29

If you don’t have access to the KMC repo it’s the output produced by the following GCC pre-processing line that CFFI can’t parse.
gcc -E -Ikmc_sdls/public_inc -I/usr/local/include -I../../../CryptoLib/include ../../public_inc/kmc_sdls.h

The root cause turned out to be with these 2 lines in crypto_structs.h
#include <stdio.h>
#include <stdlib.h>
https://github.com/nasa/CryptoLib/pull/210/files#diff-ff3b1a31169cc448e7dce70a6b076fdffe88b286df835bfdfeec10405dafde45R28
https://github.com/nasa/CryptoLib/pull/210/files#diff-ff3b1a31169cc448e7dce70a6b076fdffe88b286df835bfdfeec10405dafde45R29

When standard C libraries are included in the gcc -E (preprocessing) step, it includes the standard library contents in the pre processed output which the Python CFFI parsing code can’t handle.

One possible solution to this is to update the following block of code in https://github.com/nasa/CryptoLib/blob/dev/include/crypto_structs.h#L24 :
FROM:

#ifdef NOS3 // NOS3/cFS build is ready
#include "common_types.h"
#else // Assume build outside of NOS3/cFS infrastructure
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#endif

TO:

#ifdef NOS3 // NOS3/cFS build is ready
#include "common_types.h"
#else // Assume build outside of NOS3/cFS infrastructure
#include <stdint.h>
#ifndef CFFI_EXCLUDE // Exclude libraries that CFFI parser can’t process
#include <stdio.h>
#include <stdlib.h>
#endif
#endif

With the above update we can then run the GCC command with -D CFFI_EXCLUDE to exclude the standard libraries
gcc -E -D CFFI_EXCLUDE -Ikmc_sdls/public_inc -I/usr/local/include -I../../../CryptoLib/include ../../public_inc/kmc_sdls.h

@dccutrig dccutrig added the kmc NASA JPL KMC label Jan 23, 2024
@dccutrig dccutrig self-assigned this Jan 23, 2024
@jlucas9
Copy link
Collaborator

jlucas9 commented Jan 23, 2024

Merged to dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kmc NASA JPL KMC
Projects
Archived in project
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants