Skip to content

feat(tgc): add LLAR formula - #156

Open
MeteorsLiu wants to merge 4 commits into
mainfrom
issue/83-tgc
Open

feat(tgc): add LLAR formula#156
MeteorsLiu wants to merge 4 commits into
mainfrom
issue/83-tgc

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

Closes #83

Adds the orangeduck/tgc Formula from the Conan Center snapshot ffe30df101afd4dc95aac2f14b25bf345e64d7be.

  • Uses upstream commit e193133e43af0862f51edfb9b518e212ea084412 as the exact source version.
  • Carries the exported CMake recipe, shared/fPIC options, license install, metadata, and the Conan consumer example.
  • Local build/CI was intentionally not awaited per task instructions.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: add orangeduck/tgc formula

Solid, minimal recipe — the SHA-pinned fromVer, empty deps, license capture, the shared/fPIC matrix with a strict filter, applying CMAKE_POSITION_INDEPENDENT_CODE only for static builds, and the distinct consumer test tree (_llar_consumer) that derives paths from installDir (so cache-hit tests work) all line up with the repo conventions.

One issue is worth fixing before merge, plus a couple of minor notes below.

Main issue — lib vs lib64 install-path mismatch
CMakeLists.txt installs via GNUInstallDirs (${CMAKE_INSTALL_LIBDIR}), which resolves to lib64 on many 64-bit distros (Fedora/RHEL/openSUSE). But the formula hardcodes -L<installDir>/lib in the metadata (line 75), the test link flags (line 94), and the LD_LIBRARY_PATH/DYLD_LIBRARY_PATH (lines 102–103). On a lib64 platform the library installs under lib64 while every consumer path points at lib, so linking/loading fails and the published metadata is wrong. The sibling json-c recipe guards against exactly this: c.define "CMAKE_INSTALL_LIBDIR", "lib" with the comment "Keep a standard lib/ layout … without lib64 handling." Recommend pinning CMAKE_INSTALL_LIBDIR to lib in onBuild (or installing directly to lib/include without GNUInstallDirs). See inline comments.

Minor notes

  • Missing explanatory comments. Unlike cglm/json-c, this recipe has no comments. The non-obvious decisions deserve a line each: why it injects its own CMakeLists.txt (upstream tgc ships no CMake build), why PIC is set only for static, and the lib/lib64 handling once fixed.
  • Optional — pkg-config metadata. formula-semantics.md prefers deriving metadata from an installed .pc. Hand-built flags are acceptable here (upstream ships no .pc, matching the cglm fallback precedent), so this is optional: having the supplied CMakeLists.txt also install a relocatable tgc.pc and driving both metadata and the test through pkgconfig.use/pkgconfig.lookup would keep metadata and test in sync.

No security, performance, or dependency concerns found.

include(GNUInstallDirs)
install(TARGETS tgc
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GNUInstallDirs makes ${CMAKE_INSTALL_LIBDIR} resolve to lib64 on many 64-bit distros, but the formula hardcodes -L.../lib (see tgc_llar.gox:75, :94, :102-103). On those platforms the archive lands in lib64 and the consumer link/load fails. Pin the layout the way json-c does — c.define "CMAKE_INSTALL_LIBDIR", "lib" in onBuild — or install directly to lib/include here.


metadata := []string{
"-I" + filepath.join(installDir, "include"),
"-L" + filepath.join(installDir, "lib"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This -L.../lib (and the same at line 94) assumes a fixed lib layout, but the CMakeLists installs via GNUInstallDirs, which can produce lib64. Either pin CMAKE_INSTALL_LIBDIR=lib in this onBuild before configuring, or derive the -L path from the actual install layout, so metadata and the consumer stay correct on lib64 platforms.


if shared {
os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))!
os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These overwrite any existing LD_LIBRARY_PATH/DYLD_LIBRARY_PATH rather than prepending. Benign in an isolated CI runner, but if the toolchain relies on a pre-existing value the shared-build consumer run could break — prefer prepending installDir/lib to the current value. (Also affected by the lib/lib64 issue above.)


static void example_function() {
char *message = tgc_alloc(&gc, 64);
strcpy(message, "No More Memory Leaks!");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: this example uses strcpy but includes only <tgc.h>. It compiles today because tgc.h transitively includes <string.h>, so this is not a bug — but relying on a transitive include is fragile under stricter defaults. Adding #include <string.h> to consumerSource makes the example self-contained.

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.

Translate Conan Center tgc recipe to LLAR

1 participant