Skip to content

Prefix the internal symbols with pslp_ - #137

Merged
dance858 merged 2 commits into
mainfrom
prefix-internal-symbols
Nov 14, 2026
Merged

dance858 merged 2 commits into
mainfrom
prefix-internal-symbols

Conversation

@dance858

Copy link
Copy Markdown
Owner

Addresses the first part of #133: libPSLP exported about 240 functions with generic names (transpose, matrix_new, free_matrix, sort_ints, count_rows, ...) that can clash with the symbols of a program or library that embeds PSLP.

What changes

  • Rename header. include/core/pslp_namespace.h holds one #define name pslp_name line for each of the 227 internal functions with external linkage. CMake force-includes it (-include, /FI on MSVC) into every source file of the library and of all_tests. The sources keep the short names; only the symbols change.
  • Generator and check. cmake/pslp_symbols.sh generate <lib>... rewrites the header from built libraries. cmake/pslp_symbols.sh check <lib>... fails if an exported symbol is neither pslp_* nor listed in cmake/public_symbols.txt, or if a public function is missing.
  • CI. The CMake workflow runs the check on Linux and macOS, for Release and Debug.
  • Twelve functions made static (first commit). They were only used in the file that defines them.

The public API is unchanged: the 13 functions of PSLP_API.h are now the only unprefixed exports.

After adding a non-static internal function

Build the library and regenerate the header, passing a Release build and a Debug build with -DPSLP_BUILD_TESTING=ON so that the debug-only and test-only functions are covered:

sh cmake/pslp_symbols.sh generate build-rel/libPSLP.a build-dbg/libPSLP.a

CI fails with the name of the function if this is forgotten.

Not in this PR

  • The public names (postsolve, default_settings, run_presolver, ...) keep their names, so a host with its own postsolve still clashes. Fixing that is an API change.
  • Hidden visibility for the shared library.
  • The second part of Generic exported symbol names can clash when PSLP is embedded in another library #133 (messages printed straight to stderr).
  • A build that compiles the sources without this CMake file does not get the forced include and keeps the old unprefixed names.

Testing

On macOS: Debug and Release, shared and static, with PSLP_BUILD_TESTING=ON: all tests pass and the symbol check passes. A Release build without testing passes the check and test_cpp links. Regenerating the header from the prefixed builds reproduces it byte for byte. Adding an unlisted function makes the check fail and name it. Windows (/FI) is only covered by CI.

🤖 Generated with Claude Code

dance858 and others added 2 commits November 14, 2026 06:38
These functions had external linkage but are only used in the file that
defines them, so they were exported from libPSLP for no reason. Two of them
(update_act_bound_change, dton_tighten_dominated_row) lose their prototype in
a header; the comment moves to the definition.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
libPSLP exported about 240 functions with generic names (transpose,
matrix_new, sort_ints, ...) that can clash with the symbols of a program or
library that embeds PSLP (#133).

include/core/pslp_namespace.h holds one '#define name pslp_name' line for
every internal function with external linkage. CMake force-includes it into
every source file of the library and of the tests, so the sources keep the
short names and only the symbols change. The header is generated from the
built library by cmake/pslp_symbols.sh, and CI fails if a symbol is exported
that is neither prefixed nor one of the 13 public functions.

The public API is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@dance858
dance858 merged commit 0f25bcc into main Nov 14, 2026
19 checks passed
@dance858
dance858 deleted the prefix-internal-symbols branch November 14, 2026 20:38
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