Skip to content

Commit

Permalink
Revert "Remove linker hack (#462)". Always link dependencies statical…
Browse files Browse the repository at this point in the history
…ly. (#469)

**Issue:**
"Remove linker hack (#462)" caused internal Amazon devs to start having issues building Lambda applications.

**Investigation:**
In Amazon's internal build system, dependencies are built as both static and shared libs. "Remove linker hack (#462)"  resulted in a switch from using static libs, to using the shared libs.

Lambda applications need all their runtime dependencies explicitly packaged up. The switch to use shared libs meant devs needed to add a lot more runtime dependencies.

**Description of changes:**
Put back code that forces dependencies to be linked statically, to keep things simple and minimize runtime dependencies.
  • Loading branch information
graebm authored Apr 21, 2023
1 parent 80a1f21 commit 11eb2a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ def awscrt_ext():
extra_link_args += ['-framework', 'Security']

else: # unix
# linker will prefer shared libraries over static if it can find both.
# force linker to choose static variant by using using
# "-l:libaws-c-common.a" syntax instead of just "-laws-c-common".
#
# This helps AWS developers creating Lambda applications from Brazil.
# In Brazil, both shared and static libs are available.
# But Lambda requires all shared libs to be explicitly packaged up.
# So it's simpler to link them in statically and have less runtime dependencies.
libraries = [':lib{}.a'.format(x) for x in libraries]

# OpenBSD doesn't have librt; functions are found in libc instead.
if not sys.platform.startswith('openbsd'):
libraries += ['rt']
Expand Down

0 comments on commit 11eb2a4

Please sign in to comment.