Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_dll_string.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_DLL_STRING
  8. #
  9. # DESCRIPTION
  10. #
  11. # Tests for a bug currently in g++ 3.4.4 on Cygwin (maybe other targets
  12. # with statically linked libstdc++?) where passing an empty std::string to
  13. # a dll will cause a crash on destruction due to incorrect memory
  14. # handling. See bug 24196 in gcc's bugzilla for more details:
  15. # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196
  16. #
  17. # LICENSE
  18. #
  19. # Copyright (c) 2008 Steven Brown <swbrown@variadic.org>
  20. #
  21. # Copying and distribution of this file, with or without modification, are
  22. # permitted in any medium without royalty provided the copyright notice
  23. # and this notice are preserved. This file is offered as-is, without any
  24. # warranty.
  25. #serial 8
  26. dnl Plan: compile conftest-dll.cc, conftest-exe.cc. It has a 'crash' param
  27. dnl that can be passed. Verify the compile worked and we can run it normally
  28. dnl ok. Then, pass 'crash', test if it crashed, fail.
  29. AC_DEFUN([AX_DLL_STRING],
  30. [
  31. AC_MSG_CHECKING(if the dll string test can be compiled)
  32. cat << EOF > conftest-dll.cc
  33. [
  34. #include <string>
  35. using namespace std;
  36. void testit(std::string (*contentGet)()) {
  37. contentGet();
  38. }
  39. ]
  40. EOF
  41. cat << EOF > conftest-exe.cc
  42. [
  43. #include <string>
  44. #include <cstring>
  45. using namespace std;
  46. extern void testit(std::string (*contentGet)());
  47. std::string contentGet() {
  48. return string(""); // Anything other than empty string works.
  49. }
  50. int main(int argc, char *argv[]) {
  51. if(argc == 2 && strcmp(argv[1], "crash") == 0) {
  52. testit(&contentGet);
  53. }
  54. return 0;
  55. }
  56. ]
  57. EOF
  58. $CXX -shared $CFLAGS $CPPFLAGS conftest-dll.cc -o conftest-dll.dll >&AS_MESSAGE_LOG_FD && $CXX $CFLAGS $CPPFLAGS conftest-exe.cc conftest-dll.dll -o conftest-exe.exe >& AS_MESSAGE_LOG_FD
  59. if test x"$?" = x"0"; then
  60. AC_MSG_RESULT(yes)
  61. dnl Make sure it runs normally first.
  62. AC_MSG_CHECKING(if the dll string test is usable)
  63. if /bin/sh -c "(LD_LIBRARY_PATH=\"$PWD\" ./conftest-exe.exe)" >& AS_MESSAGE_LOG_FD 2>&1; then
  64. AC_MSG_RESULT(yes)
  65. dnl Now we can check for the bug.
  66. AC_MSG_CHECKING(if the dll string test is affected by gcc bug 24196)
  67. if ! /bin/sh -c "(LD_LIBRARY_PATH=\"$PWD\" ./conftest-exe.exe crash)" >& AS_MESSAGE_LOG_FD 2>&1; then
  68. AC_MSG_RESULT(yes)
  69. dnl We have the bug, user'll need to fix it.
  70. AC_MSG_ERROR([*** This toolchain is affected by gcc bug 24196. For Cygwin as of 4/8/2006, you can downgrade to gcc/g++ 3.3.3 or check if there is a newer compiler available that's fixed.])
  71. else
  72. AC_MSG_RESULT(no)
  73. fi
  74. else
  75. AC_MSG_RESULT(no)
  76. fi
  77. else
  78. AC_MSG_RESULT(no)
  79. fi
  80. ])