Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link-library variable to Makefiles #866

Closed
noloader opened this issue Jul 21, 2019 · 1 comment
Closed

Add link-library variable to Makefiles #866

noloader opened this issue Jul 21, 2019 · 1 comment

Comments

@noloader
Copy link
Collaborator

noloader commented Jul 21, 2019

Currently the recipe to build cryptest.exe hard-codes libcryptopp.a. From GNUmakefile:

cryptest.exe:libcryptopp.a $(TESTOBJS)
	$(CXX) -o $@ $(strip $(CXXFLAGS)) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)

Using libcryptopp.a is a good engineering decision because it sidesteps path problems that plague Unix and Linux.

However, there are two gaps. First, distros usually patch to use the shared object. Second, cryptest.sh (and some other scripts) test shared object linking, and they require makefile hacks. For example, we make a copy of the makefile, run sed over it, and then use the new makefile for testing.

We can make it easier to swap-in the shared object by introducing a makefile variable:

LINK_LIBRARY ?= ./libcryptopp.a
...

cryptest.exe: $(LINK_LIBRARY) $(TESTOBJS)
	$(CXX) -o $@ $(strip $(CXXFLAGS)) $(TESTOBJS) $(LINK_LIBRARY) $(LDFLAGS) $(LDLIBS)

This will track the changes to add the variable LINK_LIBRARY.

@noloader
Copy link
Collaborator Author

noloader commented Jul 21, 2019

The change was added at Commit 52ad132134c1 (and friends). The change allows:

$ LINK_LIBRARY=libcryptopp.so make -j 4
...
$ LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe v
...

The user is still responsible to add a path to LDFLAGS if they don't want to use LD_LIBRARY_PATH:

$ LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ldd cryptest.exe
        linux-vdso.so.1 (0x00007ffcab9eb000)
        libcryptopp.so.8 => /home/test/libcryptopp.so.8 (0x00007fd71a067000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fd719e55000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fd719d0f000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd719cf5000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd719cd4000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fd719b0e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd71a58c000)

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

No branches or pull requests

1 participant