Skip to content

Fixed MacOS-specific handling for x86_64 or arm64#127

Merged
yantosca merged 1 commit intodevfrom
bugfix/macos-darwin-build
Feb 19, 2025
Merged

Fixed MacOS-specific handling for x86_64 or arm64#127
yantosca merged 1 commit intodevfrom
bugfix/macos-darwin-build

Conversation

@yantosca
Copy link
Copy Markdown
Contributor

@yantosca yantosca commented Feb 6, 2025

This is the companion PR to #126, in which we do the following:

  • Use the GNU Make $(strip ) command to trim trailing whitespace before testing the values of variables SYSTEM and SYSTEM_M for string equality. Trailing whitespace was causing the string equality tests to fail.
  • Add -arch x86_64 to CC_FLAGS if compiling on MacOS with Linux x86_64 chipsets
  • Add -arch arm64 to CC_FLAGS if compiling on MacOS with Apple Silicon chipsets

As you can see the Mac-specific options are now added:

gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c code.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c code_c.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c code_f77.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c code_f90.c
code_f90.c:319:5: warning: variable 'nlines' set but not used [-Wunused-but-set-variable]
  319 | int nlines;
      |     ^
1 warning generated.
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c code_matlab.c
code_matlab.c:262:5: warning: variable 'nlines' set but not used [-Wunused-but-set-variable]
  262 | int nlines;
      |     ^
1 warning generated.
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c debug.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c gen.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c kpp.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c lex.yy.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c scanner.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c scanutil.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 -I/usr/include -c y.tab.c
gcc -g -Wall -Wno-unused-function -DMACOS -O -arch x86_64 code.o code_c.o code_f77.o code_f90.o code_matlab.o debug.o gen.o kpp.o lex.yy.o scanner.o scanutil.o y.tab.o -L/usr/local/Cellar/flex/2.6.4_2/lib -lfl -o kpp

Tagging @HartwigHarder

src/Makefile
- Now print the value of SYSTEM_M variable in "make list" target
- Trimmed trailing whitespace

src/Makefile.defs
- Now use the $(strip) function when testing the values of SYSTEM
  and SYSTEM_M.  This will make sure that trailing whitespace is
  removed.  This was affecting the string equality tests.
- Add option "-arch x86_64" if compiling on Intel x86_64 chipsets
- Add option "-arch arm64" if compiling on Apple Silicon chipsets
- Trimmed trailing whitespace

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added build Related to makefiles and/or compilation bugfix Fixes a bug or a technical issue labels Feb 6, 2025
@yantosca yantosca requested a review from RolfSander February 6, 2025 21:04
@yantosca yantosca self-assigned this Feb 6, 2025
@yantosca yantosca added this to the 3.2.0 milestone Feb 6, 2025
@RolfSander
Copy link
Copy Markdown
Contributor

@HartwigHarder: Can you please check if this works for you?

@HartwigHarder
Copy link
Copy Markdown

works on my system (M2)

Copy link
Copy Markdown
Contributor

@RolfSander RolfSander left a comment

Choose a reason for hiding this comment

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

As it works for @HartwigHarder, I'm happy to approve :-)

@yantosca
Copy link
Copy Markdown
Contributor Author

Thanks @RolfSander and @HartwigHarder, I'll merge this in.

@yantosca yantosca merged commit 3c0200f into dev Feb 19, 2025
@yantosca yantosca deleted the bugfix/macos-darwin-build branch February 19, 2025 17:15
yantosca added a commit that referenced this pull request Feb 19, 2025
docs/source/getting_started/00_revision_history.rst
- Added a line to KPP 3.2.0 about MacOS architecture specific build
  compiler flags

Signed-off-by: Bob Yantosca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug or a technical issue build Related to makefiles and/or compilation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] check architecture and set compiler & linker flags accordingly

3 participants