Skip to content

bc-gh: fix broken build - #15930

Open
xingyaner wants to merge 1 commit into
google:masterfrom
xingyaner:fix-bc-gh
Open

bc-gh: fix broken build#15930
xingyaner wants to merge 1 commit into
google:masterfrom
xingyaner:fix-bc-gh

Conversation

@xingyaner

Copy link
Copy Markdown
Contributor

The original build.sh failed when executing ./configure -Z. In bc version 7.2.0, configure.sh adopts the getopts string abBcdDeEfgGhHik:lmMNO:p:PrS:s:T- and no longer supports the -Z flag, resulting in an invalid option error. Previously, the -Z flag was used to enable the OSS-Fuzz build mode, while the latest version has deprecated this flag and controls the OSS-Fuzz feature exclusively via the compile-time macro BC_ENABLE_OSSFUZZ.

After removing the invalid -Z flag and adopting ./configure.sh -H -N, a latent upstream bug was exposed. The test_target variable in configure.sh contains a literal newline that spans multiple lines, breaking the sed-based substring_replace() function. Since the script uses ! as the sed delimiter, the unexpected newline in the replacement content causes an unterminated sed substitution command and leads to build failures.

This fix first patches the malformed multi-line variable before configuration execution, and invokes ./configure.sh -H -N with valid flags. The project is then fully built via make. After the default compilation, five core source files including vm.c, data.c, lex.c, bc_lex.c and dc_lex.c are recompiled with the macros -DBC_ENABLE_OSSFUZZ=1 and -DNDEBUG.

These macros enable the OSS-Fuzz-specific data loading logic inside bc_vm_exec(), and eliminate invalid references to bc_vm_readLine under the BC_MODE_STDIN branch, resolving compilation and runtime compatibility issues when OSS-Fuzz mode is enabled. The regenerated fuzz object files replace the original ones during the linking phase, and are finally linked with the two fuzzer entry points src/bc_fuzzer.c and src/dc_fuzzer.c.

Considering that OSS-Fuzz clones the upstream repository from scratch in every build, persistent local modifications are not available. Therefore, a dynamic sed patch is added to fix the configure.sh syntax issue during each build, ensuring a stable and complete compilation pipeline.

@github-actions

Copy link
Copy Markdown

xingyaner is a new contributor to projects/bc-gh. The PR must be approved by known contributors before it can be merged. The past contributors are: hunsche, gavinhoward

@DavidKorczynski DavidKorczynski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the project is set to disabled? could you please coordinate with the maintainers in terms of getting the project running please

@xingyaner

Copy link
Copy Markdown
Contributor Author

Alright, I will coordinate with the project maintainers to get bc-gh running again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants