Repository navigation
Fix build_c: ARCH test compares a literal, and CFLAGS is empty for both shared libraries - #48
Open
richard-burhans wants to merge 1 commit into
Open
richard-burhans wants to merge 1 commit into
richard-burhans wants to merge 1 commit into
Conversation
…th shared libraries
Two make/shell variable bugs in build_c:
1. `if [ ARCH = "arm64" ]` compares the literal string "ARCH" against "arm64",
so the condition is always false and the arm64 branch is unreachable.
`-arch arm64` is never passed, even when uname -m reports arm64.
2. CFLAGS is assigned in the first recipe line, but the two gcc calls for
chain_coords_converter_slib.so and chain_bst_lib.so are separate recipe
lines, and make runs each in its own shell. $$CFLAGS is empty there, so both
shared libraries are compiled with no -O2, no -std=c99 and no warnings.
Measured with a stub gcc that echoes its arguments:
before, ARCH=x86_64 and ARCH=arm64 alike:
-Wall -Wextra -O2 -g -std=c99 -o bin/chain_filter_by_id ...
-fPIC -shared -o .../chain_coords_converter_slib.so ... <- no flags
-fPIC -shared -o .../chain_bst_lib.so ... <- no flags
after, ARCH=arm64:
-Wall -Wextra -O2 -g -std=c99 -arch arm64 -o bin/chain_filter_by_id ...
-Wall -Wextra -O2 -g -std=c99 -arch arm64 -fPIC -shared -o .../chain_coords_converter_slib.so ...
-Wall -Wextra -O2 -g -std=c99 -arch arm64 -fPIC -shared -o .../chain_bst_lib.so ...
Hoisting the flags to a make variable fixes both at once and removes the
shell conditional. The name is TOGA_CFLAGS rather than CFLAGS so it is not
exported into the CESAR2.0 sub-make.
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.
Two make/shell variable bugs in
build_c, the same class as #46 — an expression that looks like shell but is resolved (or not resolved) by make.1. The arm64 branch is unreachable
ARCHhere is a bare word, not$(ARCH)or$$ARCH, so[compares the literal stringARCHagainstarm64. That is always false, theelsebranch always runs, and-arch arm64is never passed — including on Apple Silicon, whereARCH=$(shell uname -m)really does evaluate toarm64.2.
CFLAGSis empty for both shared librariesCFLAGSis assigned in the first recipe line. The twogcccalls forchain_coords_converter_slib.soandchain_bst_lib.soare separate recipe lines, and make runs each recipe line in its own shell, so$$CFLAGSis unset there. Both shared libraries are compiled with no-O2, no-std=c99, no warnings — silently, since gcc is happy to compile without them.Only
chain_filter_by_idgets the flags, because it is on the same continued line as the assignment.Measured
With a stub
gccthat echoes its arguments:The fix
Hoist the flags into a make variable with an
ifeqon$(ARCH). That fixes both problems at once and removes the shell conditional entirely. The variable is namedTOGA_CFLAGSrather thanCFLAGSso it is not exported into theCESAR2.0sub-make, which has its own build.make build_ccompiles cleanly and produces all three artifacts.