davmac314 / dinit

Service monitoring / "init" system
Apache License 2.0
582 stars 45 forks source link

configure: Don't invoke linker for checking flags for compiler #311

Closed mobin-2008 closed 5 months ago

mobin-2008 commented 5 months ago

It makes into 50% better speed (from 2s to 1s on my test subject) and actually makes sense because in "try_cxx_argument" we're looking for flags that compiles not links.

Signed-off-by: Mobin Aydinfar <mobin@mobintestserver.ir>

davmac314 commented 5 months ago

Some compiler options need link-time support, that is why both are checked.

With this change on my system:

~/workspace/dinit$ ./configure CXX=clang++
Checking whether "clang++" is a working C++ compiler...
  ... Yes.
Checking whether the compiler accepts -std=c++11...
  ... Yes.
Checking whether the compiler accepts -Wall...
  ... Yes.
Checking whether the compiler accepts -Os...
  ... Yes.
Checking whether the compiler accepts -fno-plt...
  ... Yes.
Checking whether the compiler accepts -fno-rtti...
  ... Yes.
Checking whether the compiler accepts -flto...
  ... Yes.
Checking whether the compiler accepts -fsanitize=address,undefined...
  ... Yes.
Creating mconfig...
  ... done.
Done!
~/workspace/dinit$ make
make -C build all
make[1]: Entering directory '/home/davmac/workspace/dinit/build'
make -C tools mconfig-gen
make[2]: Entering directory '/home/davmac/workspace/dinit/build/tools'
make[2]: 'mconfig-gen' is up to date.
make[2]: Leaving directory '/home/davmac/workspace/dinit/build/tools'
./tools/mconfig-gen SBINDIR=/sbin SYSCONTROLSOCKET=/run/dinitctl \
    SHUTDOWN_PREFIX= VERSION=0.18.1pre \
    DEFAULT_AUTO_RESTART=true \
    DEFAULT_START_TIMEOUT=60 \
    DEFAULT_STOP_TIMEOUT=10 \
    SUPPORT_CGROUPS=1 \
     \
    USE_INITGROUPS=1 > includes/mconfig.h
make[1]: Leaving directory '/home/davmac/workspace/dinit/build'
make -C src all
make[1]: Entering directory '/home/davmac/workspace/dinit/src'
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c dinit.cc -o dinit.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c load-service.cc -o load-service.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c service.cc -o service.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c proc-service.cc -o proc-service.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c baseproc-service.cc -o baseproc-service.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c control.cc -o control.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c dinit-log.cc -o dinit-log.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c dinit-main.cc -o dinit-main.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c run-child-proc.cc -o run-child-proc.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c options-processing.cc -o options-processing.o
clang++  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto  -MMD -MP -Iincludes -I../dasynq/include -I../build/includes -c dinit-env.cc -o dinit-env.o
clang++ -o dinit dinit.o load-service.o service.o proc-service.o baseproc-service.o control.o dinit-log.o dinit-main.o run-child-proc.o options-processing.o dinit-env.o  -std=c++11 -Wall -Os -fno-plt -fno-rtti -flto 
/usr/bin/ld: /usr/bin/x86_64-linux-gnu/../lib/x86_64-linux-gnu/LLVMgold.so: error loading plugin: /usr/bin/x86_64-linux-gnu/../lib/x86_64-linux-gnu/LLVMgold.so: cannot open shared object file: No such file or directory
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:24: dinit] Error 1
make[1]: Leaving directory '/home/davmac/workspace/dinit/src'
make: *** [Makefile:5: all] Error 2
mobin-2008 commented 5 months ago

So looks like we cannot do anything about this case, Closing...