Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
gcc_v: [12,10,11,9] # Version of GFortran we want to use.
gcc_v: [14,10,11,9] # Version of GFortran we want to use.
python-version: [3.11]
env:
FC: gfortran-${{matrix.gcc_v}}
Expand All @@ -22,7 +22,7 @@ jobs:
# 9 - build.sh with documentation, unit tests and coverage analysis. doc deployment
# 10 - build.sh - no documentation, with and without unicode.
# 11 - FPM
# 12 - CMake build with unit tests, no documentation, with coverage analysis. no unicode
# 14 - CMake build with unit tests, no documentation, with coverage analysis. no unicode
#
# NOTE: coverage disabled for now

Expand All @@ -34,41 +34,29 @@ jobs:
submodules: recursive

- name: Setup cmake
if: contains( matrix.gcc_v, 12 )
uses: jwlawson/actions-setup-cmake@v2.0.2
with:
cmake-version: '3.28.x'

- name: Install Python
uses: actions/setup-python@v5.1.0 # Use pip to install latest CMake, & FORD/Jin2For, etc.
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}

- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2.0.2

- name: Set current directory in env variable
run: echo "MYDIR=$(pwd)" >> $GITHUB_ENV

- name: Set PYTHONPATH and PATH for later steps
run: |
echo "PYTHONPATH=$MYDIR/FoBiS/src/main/python:$PYTHONPATH" >> $GITHUB_ENV
echo "PATH=$MYDIR/FoBiS/src/main/python:$PATH" >> $GITHUB_ENV
- name: Setup Fortran Package Manager
uses: fortran-lang/setup-fpm@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python dependencies
if: contains( matrix.os, 'ubuntu')
run: |
python -m pip install --upgrade pip
#pip install ford FoBiS.py pygooglechart fpm
pip install ford pygooglechart fpm
# just get the latest FoBiS from git:
# git clone https://github.com/szaghi/FoBiS.git
# use a fork until there is a new release:
git clone https://github.com/jacobwilliams/FoBiS.git
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install ford FoBiS.py pygooglechart

- name: Install GFortran Linux
if: contains( matrix.os, 'ubuntu')
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
Expand All @@ -94,13 +82,13 @@ jobs:
sudo apt update && sudo apt install -y valgrind
fpm --version
gfortran --version
fpm test "*" --runner "valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1"
fpm test "*" --link-flag "-ftrampoline-impl=heap" --runner "valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1"

- name: Compile_with_cmake
# CMake build with unit tests, no documentation, with coverage analysis
# No unicode so that coverage combined with the build script will cover unicode
# and non-unicode code paths
if: matrix.gcc_v == 12
if: matrix.gcc_v == 14
run: |
GFORTRAN=gfortran-${{matrix.gcc_v}}
GCOV=gcov-${{matrix.gcc_v}}
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ set_target_properties ( ${LIB_NAME}
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR} )

# Add trampoline heap implementation flag for gfortran on Linux
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(${LIB_NAME} PRIVATE -ftrampoline-impl=heap)
target_link_options(${LIB_NAME}-static PRIVATE -ftrampoline-impl=heap)
endif()

#-------------------------------------
# Build the documentation with FORD
#-------------------------------------
Expand Down
13 changes: 9 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ argument is passed. Additionally, A custom compiler may be passed to the 'compil
flag, but appropriate 'cflags' should also be passed to the script.\n\n"
}


while [ "$#" -ge "1" ]; do # Get command line arguments while there are more left to process

key="$1" # Command line args are key-value pairs or value-less keys
Expand Down Expand Up @@ -257,6 +256,12 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
shift # look at next argument
done # with argument parsing loop

# linker flags for gfortran:
COMPILERLFLAGS=""
if [ $FCOMPILER = gnu ]; then
COMPILERLFLAGS='-lflags "-ftrampoline-impl=heap"'
fi

# if no compiler selected, then we're defaulting to gnu, and need to check that the cflags are set
if [ "$FCOMPILER" = 'gnu' ] && [ -z "$FCOMPILERFLAGS" ]; then
FCOMPILERFLAGS="$GNUCOMPILERFLAGS"
Expand All @@ -279,7 +284,7 @@ fi

if [[ $TRY_UNICODE == [yY]* ]]; then
echo "Trying to compile library with Unicode/UCS4 support"
FoBiS.py build -ch -compiler "${FCOMPILER}" "${CUSTOM[@]}" -cflags "${FCOMPILERFLAGS}" -dbld "${BINDIR}" -s "${INTROSPECDIR}" -dmod ./ -dobj ./ -t "${UCS4TESTCODE}" -o "${UCS4TESTCODE%.f90}" -colors
FoBiS.py build -ch -compiler "${FCOMPILER}" "${CUSTOM[@]}" $COMPILERLFLAGS -cflags "${FCOMPILERFLAGS}" -dbld "${BINDIR}" -s "${INTROSPECDIR}" -dmod ./ -dobj ./ -t "${UCS4TESTCODE}" -o "${UCS4TESTCODE%.f90}" -colors
if "${BINDIR}/${UCS4TESTCODE%.f90}"; then
DEFINES="-DUSE_UCS4 -Wunused-function"
fi
Expand All @@ -289,7 +294,7 @@ fi
echo ""
echo "Building library..."

FoBiS.py build -ch -compiler ${FCOMPILER} "${CUSTOM[@]}" -cflags "${FCOMPILERFLAGS} ${DEFINES} ${REAL_KIND} ${INT_KIND}" ${COVERAGE} ${PROFILING} -dbld ${LIBDIR} -s ${SRCDIR} -dmod ./ -dobj ./ -t ${MODCODE} -o ${LIBOUT} -mklib static -colors
FoBiS.py build -ch -compiler ${FCOMPILER} "${CUSTOM[@]}" $COMPILERLFLAGS -cflags "${FCOMPILERFLAGS} ${DEFINES} ${REAL_KIND} ${INT_KIND}" ${COVERAGE} ${PROFILING} -dbld ${LIBDIR} -s ${SRCDIR} -dmod ./ -dobj ./ -t ${MODCODE} -o ${LIBOUT} -mklib static -colors

#build the unit tests (uses the above library):
if [[ $JF_SKIP_TESTS != [yY]* ]]; then
Expand All @@ -302,7 +307,7 @@ if [[ $JF_SKIP_TESTS != [yY]* ]]; then
for TEST in "${TESTDIR%/}"/jf_test_*.[fF]90; do
THIS_TEST=${TEST##*/}
echo "Build ${THIS_TEST%.[fF]90}"
FoBiS.py build -ch -compiler ${FCOMPILER} "${CUSTOM[@]}" -cflags "${FCOMPILERFLAGS} ${DEFINES}" ${COVERAGE} ${PROFILING} -dbld "${BINDIR}" -s "${TESTDIR}" -i "${LIBDIR}" -libs "${LIBDIR}/${LIBOUT}" -dmod ./ -dobj ./ -t "${THIS_TEST}" -o "${THIS_TEST%.[fF]90}" -colors
FoBiS.py build -ch -compiler ${FCOMPILER} "${CUSTOM[@]}" $COMPILERLFLAGS -cflags "${FCOMPILERFLAGS} ${DEFINES}" ${COVERAGE} ${PROFILING} -dbld "${BINDIR}" -s "${TESTDIR}" -i "${LIBDIR}" -libs "${LIBDIR}/${LIBOUT}" -dmod ./ -dobj ./ -t "${THIS_TEST}" -o "${THIS_TEST%.[fF]90}" -colors
done
else
echo "Skip building the unit tests since \$JF_SKIP_TESTS has been set to 'true'."
Expand Down
4 changes: 4 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ homepage = "https://github.com/jacobwilliams/json-fortran"
categories = ["io"]
keywords = ["JSON"]

[features]
debug.gfortran.linux.link-time-flags = "-ftrampoline-impl=heap"
release.gfortran.linux.link-time-flags = "-ftrampoline-impl=heap"

[build]
external-modules = "ifcore"
auto-executables = true
Expand Down
7 changes: 7 additions & 0 deletions json-fortran.fobis
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $FORD_FILE = ford.md
$STATIC_LIB = libjsonfortran.a
$SHARED_LIB = libjsonfortran.so
$OPTIMIZE = -O2
$LFLAGS_GNU = -ftrampoline-impl=heap
$CSTATIC_GNU = -c -fbacktrace -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-function -pedantic
$DEBUG_GNU = -O0 -g3 -Warray-bounds -Wcharacter-truncation -Wline-truncation -Wimplicit-interface -Wimplicit-procedure -Wunderflow -fcheck=all -fmodule-private -ffree-line-length-132 -fimplicit-none -fbacktrace -fdump-core -finit-real=nan -fall-intrinsics
$CSTATIC_INT = -c -std18
Expand Down Expand Up @@ -69,12 +70,14 @@ exclude_dirs = $EXCLUDE_DIRS
description = Build library with GNU gfortran by optimized-static flags
compiler = gnu
cflags = $CSTATIC_GNU $OPTIMIZE
lflags = $LFLAGS_GNU
template = template-static

[static-gnu-debug]
description = Build library with GNU gfortran by debug-static flags
compiler = gnu
cflags = $CSTATIC_GNU $DEBUG_GNU
lflags = $LFLAGS_GNU
template = template-static

[static-intel]
Expand All @@ -93,12 +96,14 @@ template = template-static
description = Build library with GNU gfortran by optimized-shared flags
compiler = gnu
cflags = $CSTATIC_GNU $OPTIMIZE
lflags = $LFLAGS_GNU
template = template-shared

[shared-gnu-debug]
description = Build library with GNU gfortran by debug-shared flags
compiler = gnu
cflags = $CSTATIC_GNU $DEBUG_GNU
lflags = $LFLAGS_GNU
template = template-shared

[shared-intel]
Expand All @@ -118,12 +123,14 @@ template = template-shared
description = Build all tests with GNU gfortran by optimized-static flags
compiler = gnu
cflags = $CSTATIC_GNU $OPTIMIZE
lflags = $LFLAGS_GNU
template = template-tests

[tests-gnu-debug]
description = Build all tests with GNU gfortran by debug-static flags
compiler = gnu
cflags = $CSTATIC_GNU $DEBUG_GNU
lflags = $LFLAGS_GNU
template = template-tests

[tests-intel]
Expand Down
Loading