-
Notifications
You must be signed in to change notification settings - Fork 0
Modify source file to load curl library at runtime #80
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
Conversation
|
Adding before and after log snippets on one of the platforms: Before: 2025-05-28-11:36:37, LOG , ut_console.c, 639 : Running Test : 'kvp single include url'
2025-05-28-11:36:37, ERROR , ut_kvp.c, 979 : Error: curl_easy_perform() failed: Couldn't resolve host name
2025-05-28-11:36:37, ERROR , ut_kvp.c, 979 : Error: curl_easy_perform() failed: Couldn't resolve host name
2025-05-28-11:36:37, ERROR , ut_kvp.c, 979 : Error: curl_easy_perform() failed: Couldn't resolve host name
---
"1":
value: true
2025-05-28-11:36:37, LOG , ut_console.c, 661 : Test Complete : 'kvp single include url'
2025-05-28-11:36:37, LOG , ut_console.c, 633 : After: 2025-05-28-11:41:08, LOG , ut_console.c, 639 : Running Test : 'kvp single include url'
2025-05-28-11:41:08, DEBUG , ut_kvp.c, 85 : Initializing curl symbols from /usr/lib/libcurl.so.4
2025-05-28-11:41:08, ERROR , ut_kvp.c, 1041 : Error: curl_easy_perform() failed: Couldn't resolve host name
2025-05-28-11:41:08, ERROR , ut_kvp.c, 1041 : Error: curl_easy_perform() failed: Couldn't resolve host name
2025-05-28-11:41:08, ERROR , ut_kvp.c, 1041 : Error: curl_easy_perform() failed: Couldn't resolve host name
---
"1":
value: true
2025-05-28-11:41:08, LOG , ut_console.c, 661 : Test Complete : 'kvp single include url'Also, adding the logs here: Size dfference: ls -lah libut_control.so
-rwxr-xr-x 1 root root 19.6M May 16 06:24 libut_control.soAfter: ls -lah libut_control.so
-rwxr-xr-x 1 root root 4.8M May 28 11:40 libut_control.so |
|
Adding before and after log snippets on linux: Before: 2025-05-28-11:53:22, LOG , ut_console.c, 639 : Running Test : 'kvp single include url'---
"1":
value: true
"2":
value: true
"3":
value: true
"4":
value: true
2025-05-28-11:53:23, LOG , ut_console.c, 661 : Test Complete : 'kvp single include url'After: 2025-05-28-11:30:55, LOG , ut_console.c, 639 : Running Test : 'kvp single include url'
2025-05-28-11:30:55, DEBUG , ut_kvp.c, 85 : Initializing curl symbols from /usr/lib/x86_64-linux-gnu/libcurl.so.4---
"1":
value: true
"2":
value: true
"3":
value: true
"4":
value: true
2025-05-28-11:30:56, LOG , ut_console.c, 661 : Test Complete : 'kvp single include url'Also attaching full logs here: |
|
logs from release test script: ./release-test-script-ut-control.sh -t feature/gh79-ut-control-reduce-size
==========================================================
RESULTS for ubuntu
On the branch feature/gh79-ut-control-reduce-size. PASS
build/linux/curl/lib/libcurl.a exists. PASS
Openssl static lib does not exist. PASS
CMake host binary does not exist. PASS
==========================================================
==========================================================
RESULTS for VM-SYNC
On the branch feature/gh79-ut-control-reduce-size. PASS
build/linux/curl/lib/libcurl.a exists. PASS
build/linux/openssl/lib/libssl.a exists. PASS
host-tools/CMake-3.30.0/build/bin/cmake exists. PASS
==========================================================
==========================================================
RESULTS for dunfell_arm
On the branch feature/gh79-ut-control-reduce-size. PASS
build/arm/curl/lib/libcurl.a exists. PASS
build/arm/openssl/lib/libssl.a exists. PASS
CMake host binary does not exist. PASS
==========================================================
==========================================================
RESULTS for dunfell_linux
On the branch feature/gh79-ut-control-reduce-size. PASS
CURL static lib does not exist. PASS
Openssl static lib does not exist. PASS
CMake host binary exists. PASS
==========================================================
==========================================================
RESULTS for kirkstone_arm
On the branch feature/gh79-ut-control-reduce-size. PASS
build/arm/curl/lib/libcurl.a exists. PASS
build/arm/openssl/lib/libssl.a exists. PASS
CMake host binary does not exist. PASS
==========================================================
==========================================================
RESULTS for kirkstone_linux
On the branch feature/gh79-ut-control-reduce-size. PASS
build/linux/curl/lib/libcurl.a exists. PASS
Openssl static lib does not exist. PASS
CMake host binary does not exist. PASS
==========================================================
|
Makefile
Outdated
| LIBCURL_PATH="/usr/lib/libcurl.so.4" | ||
| else | ||
| #linux case | ||
| LIBCURL_PATH="/usr/lib/x86_64-linux-gnu/libcurl.so.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.4 i don't think is right, the main .so should be a symlink to the right version do an ls -la on the directory. The .4 version of the library will depend on what version of curl is installed and it may not exist but the .so should always. Google the rules for the .so linkage etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Response from chatgpt:
Yes, you can pass the path /usr/lib/x86_64-linux-gnu/libcurl.so.4 to your dlopen code and it should work correctly.
Here’s why:
🔹 libcurl.so.4 is a symlink
Your ls -la output confirms:
libcurl.so.4 -> libcurl.so.4.7.0
This means that libcurl.so.4 is a symbolic link to the actual shared library libcurl.so.4.7.0.
When using dlopen() in your code, you can pass:
dlopen("/usr/lib/x86_64-linux-gnu/libcurl.so.4", RTLD_NOW);
This will resolve correctly because the symlink points to a valid ELF shared object file (libcurl.so.4.7.0), which contains the symbols you need.
ls -la /usr/lib/x86_64-linux-gnu/libcurl.*
lrwxrwxrwx 1 root root 16 Dec 11 17:26 /usr/lib/x86_64-linux-gnu/libcurl.so.4 -> libcurl.so.4.7.0
-rw-r--r-- 1 root root 677656 Dec 11 17:26 /usr/lib/x86_64-linux-gnu/libcurl.so.4.7.0There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup you've made my point.
libcurl.so is a sym link to the latest installed library
libcurl.so.4 is version 4 of the curl library which may or may not be installed, your checking for a min version of the library, not a max version of it.
so libcurl.so is correct.. libcurl.so.4 is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My problem here is different servers are giving different output .For ex:
jpn323@ceres ~/workspace/ut-core-1April/scripts (feature/gh#208-print-version)$ find /usr/ -type l -iname "libcurl.so*"
/usr/lib/x86_64-linux-gnu/libcurl.so.4
/usr/lib/x86_64-linux-gnu/libcurl.sojpn323@janus ~/workspace/ut-control-reduce-size/tests/build/bin (feature/gh79-ut-control-reduce-size)$ find /usr/ -type l -iname "libcurl.so*"
/usr/lib/x86_64-linux-gnu/libcurl.so.4I have hence come up with a common solution, that will provide me the first symlink when I try to find the library.
Makefile
Outdated
| LIBCURL_PATH="/usr/lib/libcurl.so.4" | ||
| else | ||
| #linux case | ||
| LIBCURL_PATH="/usr/lib/x86_64-linux-gnu/libcurl.so.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup you've made my point.
libcurl.so is a sym link to the latest installed library
libcurl.so.4 is version 4 of the curl library which may or may not be installed, your checking for a min version of the library, not a max version of it.
so libcurl.so is correct.. libcurl.so.4 is not.
|
Attaching the debug logs when run with |
| $(ROOT_DIR)/build.sh | ||
| make -C ./ut-core test | ||
| @cp $(LIB_DIR)/lib* ${BIN_DIR} | ||
| @if [ -d $(LIB_DIR)/../curl ]; then \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes no sense.
the test builds test, it has no-idea what ut-control builds, wants to build or what it has internally to it.
the test calls the main ut-control makefile, which builds whatever libraries it requires ( which are copied to the output directory ), because that's what the ut-control makefile knows about.
| # For linux | ||
| if [ "$OPENSSL_IS_SYSTEM_INSTALLED" -eq 1 ]; then | ||
| ./configure --prefix=${CURL_BUILD_DIR} --with-ssl --without-zlib --without-libpsl --without-libidn2 --disable-docs --disable-libcurl-option --disable-alt-svc --disable-headers-api --disable-hsts --without-libgsasl | ||
| ./configure --prefix=${CURL_BUILD_DIR} --with-ssl --without-zlib --without-libpsl --without-libidn2 --disable-docs --disable-libcurl-option --disable-alt-svc --disable-headers-api --disable-hsts --without-libgsasl --enable-shared --enable-static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand this correctly
shared - because you load the .so in the dlopen right?
static - because for external consumption you take ut-control.so & include the .a into that .so?
you may need to also consider stripped the symbols for the external libraries from ut-control.so, because you may not get what you expect..
say ut-control.so is loaded by you, which your expecting the libcurl.a also to be loaded.
But in the same process, someone else already loaded their libcurl.a, the one that's already present will then be used not your one.
that's the disadvantages of not having static libraries which you control embedded into your .so's
|
Modify ut_kvp.c file to load curl library at runtime. This reduces the size of libut_control.so to upto 4.8M from 15M.
Also, didn't notice any change in functionality.