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

MNT: Add support for osx-64 builds #2

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Jan 4, 2025

  • Add osx-64 builds.
  • Change -fstack-protector FFLAGS flag to -no-fstack-protector for x86 osx builds to allow for the share/*.dat files to be loaded properly. osx-arm64 sets -no-fstack-protector, so this is mirroring that behavior.
  • Bump build number.

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • [N/A] Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

@matthewfeickert matthewfeickert self-assigned this Jan 4, 2025
@matthewfeickert
Copy link
Member Author

@conda-forge-admin, please rerender

@conda-forge-admin
Copy link
Contributor

conda-forge-admin commented Jan 4, 2025

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe/meta.yaml) and found it was in an excellent condition.

I do have some suggestions for making it better though...

For recipe/meta.yaml:

  • ℹ️ The recipe is not parsable by parser conda-recipe-manager. The recipe can only be automatically migrated to the new v1 format if it is parseable by conda-recipe-manager.

This message was generated by GitHub Actions workflow run https://github.com/conda-forge/conda-forge-webservices/actions/runs/12783159295. Examine the logs at this URL for more detail.

@matthewfeickert matthewfeickert force-pushed the enh/add-macos-x86-build-support branch from 618b21e to a2ea56b Compare January 5, 2025 09:43
+* default to the system directory
+ path = '/usr/local/share/ff/'
+
+ fullname = trim(path)//trim(name)
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think Fortran 90 code (like trim) can be added to Fortran 77 .f files. So will need to get an equivalent to trim working.

* Add osx-64 builds.
* Bump build number.
@matthewfeickert matthewfeickert force-pushed the enh/add-macos-x86-build-support branch from a2ea56b to 0ff11f1 Compare January 5, 2025 23:16
@matthewfeickert
Copy link
Member Author

@conda-forge-admin, please rerender

@matthewfeickert matthewfeickert changed the title MNT: Remove fstack-protector flag to allow for osx-64 builds MNT: Add support for osx-64 builds Jan 5, 2025
@matthewfeickert
Copy link
Member Author

@conda-forge/staged-recipes I'm not sure if anyone with Fortran experience can offer advice here, but this recipe currently builds and runs as expected for linux-64, linux-aarch64, linux-ppc64le, and osx-arm64. To make this legacy code installable (the original author is dead and I do not develop Fortran — this is Fortran 77) file paths that the author expected individual users to hardcode for their machines get patched at recipe build time with sed to inject $PREFIX.

- sed -i "s|/user/gj/lib/|$PREFIX/share/ff/ |g" src/ff/ffinit.f
- sed -i "s|/usr/local/ff/|$PREFIX/share/ff/ |g" src/ff/ffinit.f

However, when trying to add in support for osx-64 I run into a runtime issue where the open command fails to be able to read the path

$PREFIX/share/ff/fferr.dat

which does exist

- test -f $PREFIX/share/ff/fferr.dat
- test -f $PREFIX/share/ff/ffperm5.dat
- test -f $PREFIX/share/ff/ffwarn.dat

and instead reports failing to open the path

/Users/runner/minifferr.dat

with

open: error: could not open /Users/runner/minifferr.dat

where /Users/runner/mini are the first 19 characters of $PREFIX for the conda-build process for osx-64.

I originally assumed that this had to come down to some strange difference in FFLAGS being set by fortran-compiler across different platforms, given that both Linux and macOS use gfortran for fortran-compiler but after testing the build process outside of conda-build as a pixi project on a macOS x86 GitHub Actions runner and having everything pass at runtime as expected (https://github.com/matthewfeickert/debug-ff-macos-delete) it seems that this is not a compiler/linker flag issue but a problem between something in the Fortran 77 code and the conda-build $PREFIX path. I had attempted to work around issues with the $PREFIX path length earlier by patching in a longer character length for the relevant variable, but that doesn't seem to be the issue here.

Can you offer any advice on how to attempt to debug this?

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Jan 6, 2025

The (I assume) relevant bits of the sed injected patched src/ff/ffinit.f from @isuruf's cat commit (also thanks for taking a look at this!):

*	first try - my home directory
	path = '/Users/runner/miniforge3/conda-bld/ff_1736136218744/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/share/ff/ '
	fullname = path(1:index(path,' ')-1)//name
	open(ifile,file=fullname,status='OLD',err=30)
	return
   30	continue
*	second try - the system directory
	path = '/Users/runner/miniforge3/conda-bld/ff_1736136218744/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/share/ff/ '
	fullname = path(1:index(path,' ')-1)//name
	open(ifile,file=fullname,status='OLD',err=40)
	return
*	file could not be found
   40	continue
	print *,'ffopen: error: could not open ',fullname
	print *,'        adjust path in ffopen (ffinit.f)'
	ier = -1
*###] ffopen:

@matthewfeickert
Copy link
Member Author

Maybe relevant environmental flags:

FFLAGS=-march=core2 -mtune=haswell -ftree-vectorize -fPIC -fstack-protector -O2 -pipe -isystem $PREFIX/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/ff_1736136218744/work=/usr/local/src/conda/ff-static-2.0.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Jan 15, 2025

Looking at the full log for the osx-64 build from #2 (comment): osx-64_full_log.txt

I see now that the test program output

+ ./npointes
 ====================================================
   FF 2.0, a package to evaluate one-loop integrals
 written by G. J. van Oldenborgh, NIKHEF-H, Amsterdam
 ====================================================
 for the algorithms used see preprint NIKHEF-H 89/17,
 'New Algorithms for One-loop Integrals', by G.J. van
 Oldenborgh and J.A.M. Vermaseren, published in 
 Zeitschrift fuer Physik C46(1990)425.
 ====================================================
 ffini: precx =    4.4408920985006262E-016
 ffini: precc =    4.4408920985006262E-016
 ffini: xalogm =    4.9406564584124654E-324
 ffini: xclogm =    4.9406564584124654E-324
  0.0000000000000E+00 0.9156199386460E+06
 NPOIN: warning: D4 is not yet supported
 NPOIN: warning: B1' seems also not yet supported
 -0.3100623399361E+02-0.2054369006935E+03-0.5269961187649E-14-0.1218492318111E-08
  0.0000000000000E+00 0.1997630170032+305-0.1033542556010E+02-0.6793071440282E+02
 open: error: could not open ��/Users/runner/miniffwarn.dat                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
         adjust path in ffopen (ffinit.f)
ffwarn: warning cannot open ffwarn.dat with warning texts
 -0.0000000000000E+00 0.1739461728624E-08-0.0000000000000E+00-0.1286491875423E-08
  0.0000000000000E+00 0.4952559280190E-18-0.0000000000000E+00-0.4571732002955E-18
 ALIJ: error: not implemented
  0.0000000000000E+00
 open: error: could not open ��/Users/runner/minifferr.dat                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
         adjust path in ffopen (ffinit.f)
fferr:  warning cannot open fferr.dat with error texts
f
total number of errors and warnings
===================================
fferr: no errors
ffwarn:        1 times  18: ffwarn:  warning:   illegal value for ierr                                      
     (lost at most a factor     8.20    )
ffwarn:        1 times 129: ffwarn:  warning:   illegal value for ierr                                      
     (lost at most a factor     9.75    )
ffwarn:       10 times 163: ffwarn:  warning:   illegal value for ierr                                      
Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW_FLAG IEEE_DENORMAL
     (lost at most a factor     244.    )
ffwarn:        1 times 164: ffwarn:  warning:   illegal value for ierr                                      
     (lost at most a factor     8.33    )
f

has the error

 open: error: could not open ��/Users/runner/miniffwarn.dat 

so it seems that for x86 macOS only

	path = '/Users/runner/miniforge3/conda-bld/ff_1736136218744/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/share/ff/ '
	fullname = path(1:index(path,' ')-1)//name
	open(ifile,file=fullname,status='OLD',err=30)

is somehow getting null(?) charecters placed at the front of fullname?

Copy link

@martin-g martin-g left a comment

Choose a reason for hiding this comment

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

OSX sed command behaves differently than GNU sed when -i is used.

Another solution is to add sed as a build requirement to the recipe.

recipe/meta.yaml Show resolved Hide resolved
recipe/meta.yaml Show resolved Hide resolved
@matthewfeickert
Copy link
Member Author

OSX sed command behaves differently than GNU sed when -i is used.

Another solution is to add sed as a build requirement to the recipe.

Thanks for your review, @martin-g. sed is already a build requirement of the recipe

build:
- {{ stdlib('c') }}
- {{ compiler('fortran') }}
- make
- libtool
- sed

specifically to avoid the OS level pattern differences that you mention. I'm quite thankful that conda-forge sed is gsed so that people don't have to worry about these in differences in general!

@martin-g
Copy link

Ah, sorry! I didn't check before typing ... Then it must be something else

@martin-g

This comment was marked as off-topic.

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.

4 participants