AdaCore / AdaCore/aws

Alr with fails: zlib/trees.o: relocation R_X86_64_PC32 against symbol `_length_code'

Open
#356 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
162
Forks
45
PR merge metrics
No merged PRs in 30d

Description

This same error occurs when you try to alr build a project that actually uses aws, but the repro steps are easier than that; just create a new project with Alire and add aws as a dependency and you get this error:

aws_21.0.0_57fddf8f/.build/x86_64-linux-gnu/release/relocatable/obj/zlib/trees.o: relocation R_X86_64_PC32 against symbol `_length_code' can not be used when making a shared object; recompile with -fPIC

Reproduction steps:

  • Create a new project alr init --bin hello_aws; cd hello_aws
  • Add aws alr with aws

You get this error:

/home/tama/.config/alire/cache/dependencies/gnat_native_11.2.4_2f37a10b/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/tama/code/ada/hello_aws/alire/cache/dependencies/aws_21.0.0_57fddf8f/.build/x86_64-linux-gnu/release/relocatable/obj/zlib/trees.o: warning: relocation against `_length_code' in read-only section `.text'
/home/tama/.config/alire/cache/dependencies/gnat_native_11.2.4_2f37a10b/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/tama/code/ada/hello_aws/alire/cache/dependencies/aws_21.0.0_57fddf8f/.build/x86_64-linux-gnu/release/relocatable/obj/zlib/trees.o: relocation R_X86_64_PC32 against symbol `_length_code' can not be used when making a shared object; recompile with -fPIC
/home/tama/.config/alire/cache/dependencies/gnat_native_11.2.4_2f37a10b/bin/../lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
gprlib: /home/tama/.config/alire/cache/dependencies/gnat_native_11.2.4_2f37a10b/bin/gcc execution error
gprbuild: could not build library for project zlib
make: *** [Makefile:184: build-native] Error 4
error: A post-fetch action failed, re-run with -vv -d for details

Googling gives lots of results of solutions to this problem in other C libraries, and the solution is to add -fPIC to dependencies from the bottom up. I'm not sure how to do that for AWS.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with alr init --bin hello_aws followed by alr with aws, then inspect the AWS dependency build path around zlib/trees.o and the Makefile:184 build-native target. Trace how gprbuild compiles zlib and verify that the dependency build completes without the relocation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, c
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.