Skip to content

CI: draft FreeBSD source-build workflow (test run) - #2

Closed
willend wants to merge 19 commits into
mainfrom
freebsd-ci
Closed

willend wants to merge 19 commits into
mainfrom
freebsd-ci

Conversation

@willend

@willend willend commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Test-run PR on the fork, only to trigger the new freebsd workflow via pull_request. Branched off mccode-dev#2895 (nexus-native-hdf5), so its commits appear here too.

The workflow builds McStas and McXtrace from source in a FreeBSD 14.2 VM (cross-platform-actions/[email protected], as MCPL/NCrystal do), then runs Test_RNG_rand01 and test_nexus_output.py --np 2.

Not for merging.

🤖 Generated with Claude Code

willend and others added 19 commits October 22, 2026 17:33
Implement the subset of the NeXus API used by McCode and the Monitor_nD
libraries (NXopen/close, make/open/closegroup, (comp)makedata(64),
open/close/putdata, putslab64, putattr, getinfo64, getgroupinfo,
getgroupID, makelink, error reporting) directly on HDF5 in mccode-r.c,
with the same names so components using nxhandle keep compiling.
The written layout (groups, NX_class, string types, chunking, shuffle +
deflate level, links and 'target' attributes) matches libNeXus 4.4.3,
verified with h5dump -p/h5diff on serial, list-flush, --IDF and MPI (VDS)
runs for McStas and McXtrace.

The open groups are a stack of HDF5 ids: no fixed path buffers, a failed
open does not change the state, over-closing is reported, nested error
suppression nests, and chunks are kept below the 4 GiB HDF5 limit.

Fixes in the NeXus writers:
- nxstr used the value as printf format: string parameters, titles or
  instrument text with '%' were garbled (e.g. "a%sb" -> "aa%sbb") or UB.
  Values are now passed as "%s", without the 1024-char buffer.
- Monitor_nD BINS output wrote uninitialised MCDETECTOR fields (Date,
  xylimits, ... seen as stack garbage in MPI runs); zero it.
- uninitialised NXlink used for /entry/data links when a group failed to
  open; unbalanced closegroup in mcdatainfo_out_nexus and the IDF group.
- existing files were opened with mode NXACC_CREATE5|NXACC_RDWR (7).
- nxhandle was defined in the header (duplicate symbol with -fno-common
  when the runtime is not embedded); siminfo_out() wrote to the NeXus
  handle as a FILE*.
- drop a debug printf in mcdetector_out_3D_nexus and the duplicated
  zmin/zmax geometry attributes in Monitor_nD.

Output changes: no root NX_class is written (as libNeXus 4.4.3), the
file_time offset is now correct during DST, NeXus_version stays "4.4.2".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
They belong to the UB_matrix work on ub-matrix-injector and were picked up
here by accident from a shared working tree. Nothing on this branch uses them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test_NeXus_output.instr with test_nexus_output.py, run by the basictest
workflows after the MPI list test. It runs the instrument with
--format=NeXus, serial and with MPI, and checks mccode.h5 with h5py:

- string values containing '%' are stored as given (instrument
  parameter and component parameter literal)
- all string attributes and data sets are printable (no uninitialised
  memory, as in the Monitor_nD BINS output)
- no debug output on stdout
- a monitor file name of 1000 characters does not crash the run
- --append adds entry2 to mccode.h5

With the current napi-based writer the first four fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts with the napi fixes of mccode-dev#2889 in mccode-r.c/mccode-r.h.in are
resolved in favour of the native HDF5 layer, which already contains them.
The napi-only workarounds merged from mccode-dev#2889 are dropped here: the native
layer has no 1024-character path buffers (long monitor names are written,
not skipped) and NXcompmakedata64 already keeps chunks below 4 GiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NeXus output needs HDF5 only since the native HDF5 writer:

- conda: hdf5 instead of libnexus in mccode-create-conda-yml (used by
  the conda CI jobs, so these now build without libNeXus present); drop
  'nexus' from environment.yml and the Windows meta-pkg environments
  (they already list hdf5)
- remove 3rdparty/nexus-package (it packaged libNeXus) with its sync.sh
  clone and the GhostBSD mkdist line
- mccode-build-conda: no -DNEXUSLIB/-DNEXUSINCLUDE, the conda NEXUSFLAGS
  already use $CONDA_PREFIX/include and lib
- basictest workflows: install libhdf5-dev (Linux) / hdf5 (Homebrew)
  instead of libnexus-dev / nexusformat, no -DNEXUSLIB/-DNEXUSINCLUDE
- toolchains: Debian ones set NEXUSFLAGS fully, drop the unused
  NEXUSLIB/NEXUSINCLUDE; macOS/MinGW NEXUSINCLUDE points at the conda
  include dir holding hdf5.h instead of include/nexus
- code generator: hint '-DUSE_NEXUS -lhdf5' instead of '-lNeXus'
- manuals (McStas, McXtrace), ILL_H16_IN5_Mantid and the macOS
  dependency README: HDF5 instead of libNeXus, -lhdf5 instead of -lNeXus

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Builds in a FreeBSD 14.2 VM via cross-platform-actions, as MCPL and
NCrystal do, then runs Test_RNG_rand01 and the NeXus output test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The generated-code preamble sets _POSIX_C_SOURCE, which on FreeBSD hides
XSI declarations such as gettimeofday (glibc gets them via _GNU_SOURCE).
_XOPEN_SOURCE=700 makes XSI visible again; headers only, no numerical change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mctest RNG checksum + basic instruments (minus MCPL/NCrystal/KDSource/xraylib),
MPI list, NeXus and mcplot-loader tests; output and failed-test logs uploaded
with the basictest artifact naming.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@willend

willend commented Oct 27, 2026

Copy link
Copy Markdown
Owner Author

FreeBSD CI green (run 40557504805). Closing this fork test PR; squashed branch goes upstream to mccode-dev/McCode.

@willend willend closed this Oct 27, 2026
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.

1 participant