monero-project / monero

Monero: the secure, private, untraceable cryptocurrency
https://getmonero.org
Other
8.73k stars 3.07k forks source link

Compilation errors on gcc 14.1.1 #9359

Open moneroexamples opened 2 weeks ago

moneroexamples commented 2 weeks ago

Regarding:

error: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]

and

error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

/home/mwo/monero/external/miniupnp/miniupnpc/listdevices.c: In function ‘add_device’:
/home/mwo/monero/external/miniupnp/miniupnpc/listdevices.c:60:24: error: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]
   60 |         elt->descURL = strdup(dev->descURL);
      |                        ^~~~~~
      |                        strcmp
/home/mwo/monero/external/miniupnp/miniupnpc/listdevices.c:60:22: error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   60 |         elt->descURL = strdup(dev->descURL);
      |                      ^
make[3]: *** [external/miniupnp/miniupnpc/CMakeFiles/listdevices.dir/build.make:76: external/miniupnp/miniupnpc/CMakeFiles/listdevices.dir/listdevices.c.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:1307: external/miniupnp/miniupnpc/CMakeFiles/listdevices.dir/all] Error 2
make[1]: *** [Makefile:146: all] Error 2
make[1]: Leaving directory '/home/mwo/monero/build/release'
make: *** [Makefile:103: release-all] Error 2
SyntheticBird45 commented 2 weeks ago

Confirm, same issue on updated Arch Linux

SyntheticBird45 commented 2 weeks ago

@selsta Applied pastebin modifications. Failed at 24%:

[scrubbed]/monero/external/miniupnp/miniupnpc/src/minihttptestserver.c:299:25: error: implicit declaration of function 'usleep'; did you mean 'sleep'? [-Wimplicit-function-declaration]
  299 |                         usleep(10000); /* 10ms */
      |                         ^~~~~~
      |                         sleep
make[2]: *** [external/miniupnp/miniupnpc/CMakeFiles/minihttptestserver.dir/build.make:76: external/miniupnp/miniupnpc/CMakeFiles/minihttptestserver.dir/src/minihttptestserver.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1341: external/miniupnp/miniupnpc/CMakeFiles/minihttptestserver.dir/all] Error 2
SyntheticBird45 commented 2 weeks ago

Compiled successfully from https://github.com/selsta/monero/tree/miniupnpc-2.2.8

0xFFFC0000 commented 2 weeks ago

After adding a small print to src/p2p/CMakeLists.txt :

get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

get_target_property(dirs miniupnpc::miniupnpc INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
  message(STATUS "miniupnpc::miniupnpc INCLUDE_DIRECTORIES='${dir}'")
endforeach()

get_target_property(dirs miniupnpc::miniupnpc INTERFACE_INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
  message(STATUS "miniupnpc::miniupnpc INTERFACE_INCLUDE_DIRECTORIES='${dir}'")
endforeach()

message(WARNING "p2p:")
get_target_property(dirs p2p INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
  message(STATUS "p2p INCLUDE_DIRECTORIES='${dir}'")
endforeach()
get_target_property(dirs p2p INTERFACE_INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
  message(STATUS "p2p INTERFACE_INCLUDE_DIRECTORIES='${dir}'")
endforeach()

you can see this output (even if you add miniupnpc::miniupnpc to p2p as dependency):

-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/rapidjson/include'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/easylogging++'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/src'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/contrib/epee/include'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/supercop/include'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/build-release/generated_include'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/build-release/translations'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='$<BUILD_INTERFACE:/home/0xfffc/developments/monero/external/miniupnp/miniupnpc/include>'
-- miniupnpc::miniupnpc INCLUDE_DIRECTORIES='$<INSTALL_INTERFACE:include/miniupnpc>'
-- miniupnpc::miniupnpc INTERFACE_INCLUDE_DIRECTORIES='$<BUILD_INTERFACE:/home/0xfffc/developments/monero/external/miniupnp/miniupnpc/include>'
-- miniupnpc::miniupnpc INTERFACE_INCLUDE_DIRECTORIES='$<INSTALL_INTERFACE:include/miniupnpc>'
-- miniupnpc::miniupnpc INTERFACE_INCLUDE_DIRECTORIES='$<INSTALL_INTERFACE:include>'
CMake Warning at src/p2p/CMakeLists.txt:71 (message):
  p2p:
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/rapidjson/include'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/easylogging++'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/src'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/contrib/epee/include'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/supercop/include'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/build-release/generated_include'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/build-release/translations'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include'
-- p2p INCLUDE_DIRECTORIES='/home/0xfffc/developments/monero/external/db_drivers/liblmdb'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include/hidapi'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include/libusb-1.0'
-- p2p INCLUDE_DIRECTORIES='/opt/monero/build-release/x86_64-pc-linux-gnu/include'
-- p2p INTERFACE_INCLUDE_DIRECTORIES='dirs-NOTFOUND'

It is obvious for some reason the include path from miniupnpc::miniupnpc does not propagate to the p2p target.

And this is the PR causing it: https://github.com/miniupnp/miniupnp/pull/559

0xFFFC0000 commented 1 week ago

In case you want to take a look at early PR, this one is a complete fix, other than a few minor issues I expect it to work without issue https://github.com/0xFFFC0000/monero/pull/23

Once it passed all the tests, I will submit a PR.

SyntheticBird45 commented 1 week ago

@0xFFFC0000 testing

SyntheticBird45 commented 1 week ago

@0xFFFC0000 unable to compile from your branch. Still have error: external/miniupnp/miniupnpc/src/minihttptestserver.c:299:25: error: implicit declaration of function 'usleep'; did you mean 'sleep'? [-Wimplicit-function-declaration]

What I did:

$ git clone https://github.com/0xFFFC0000/monero -b dev/0xfffc/new-miniupnpc && cd monero/
$ git submodule update --init --force
$ make -j 8
0xFFFC0000 commented 1 week ago

Yes. That is their error. Not ours. Even if you compile miniupnpc in separate environment with same compiler, you will hit it. ( in your spare time please try it if possible and let me know )

Let me double check though, I will find a workaround.

0xFFFC0000 commented 1 week ago

@0xFFFC0000 unable to compile from your branch. Still have error: external/miniupnp/miniupnpc/src/minihttptestserver.c:299:25: error: implicit declaration of function 'usleep'; did you mean 'sleep'? [-Wimplicit-function-declaration]

What I did:

$ git clone https://github.com/0xFFFC0000/monero -b dev/0xfffc/new-miniupnpc && cd monero/
$ git submodule update --init --force
$ make -j 8

Do you use Element? or IRC?

0xFFFC0000 commented 1 week ago
if(NOT MSVC)              
  add_compile_options(-D_GNU_SOURCE)
endif()

Fixed the issue. Now we have updated miniupnpc and fixed this compilation issue.