Skip to content

Conversation

@gkodinov
Copy link
Contributor

@gkodinov gkodinov commented Jan 9, 2026

Fix the warnings issued by a normal MacOSX compile.

Problems:

  1. sprintf is deprecated in favor of snprintf
  2. bison incorrectly issues a warning when it sees "b4_bin"
  3. MacOSX linker issues a warning about duplicate mysys/dbug/etc libraries.

On 1: replaced the relevant sprintf with snprintf. On 2: worked around by adding a compiler define with a different name
aliasing the character set variable used with a name that
won't trigger the bison warning
On 3: This is due to the fact that there's a circular dependecy between
mysys and dbug (among others). Turned the warning off by adding a macro
to suppress the duplicate library warning.
Applied the macro to all targets that have a dependency on
the mysys/dbug/strings libraries

@gkodinov gkodinov added the MariaDB Foundation Pull requests created by MariaDB Foundation label Jan 9, 2026
@gkodinov gkodinov requested a review from vaintroub January 9, 2026 13:00
# TODO: to remove the circular dependency and this workaround.
IF(APPLE AND (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13"))
CHECK_LINKER_FLAG(C "LINKER:-no_warn_duplicate_libraries" HAVE_NO_WARN_DUPLICATE_LIBRARIES)
IF(HAVE_NO_WARN_DUPLICATE_LIBRARIES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move INCLUDE(CheckLinkerFlag) here, from top-level CMake, under IF(), before using CHECK_LNKER_FLAG. I looked into documentation, it turns out CHECK_LNKER_FLAG needs CMake 3.18, thus CMAKE version check needs to be VERSION_GREATER_EQUAL "3.18"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

CMakeLists.txt Outdated
MARK_AS_ADVANCED(WITH_PIC)
ENDIF()

include(CheckLinkerFlag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove it from top level CMake, as discussed above, and only use in the single place where the macro is used in mysys/CMakeLists.txt .
CheckLinkerFlags needs CMake 3.18, currently we declare the minimum version as 3.12, so it might not work with downlevel CMake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

  mariadb from a git tree

Fix the warnings issued by a normal MacOSX compile.

Problems:
1. sprintf is deprecated in favor of snprintf
2. bison incorrectly issues a warning when it sees "b4_bin"
3. MacOSX linker issues a warning about duplicate mysys/dbug/etc libraries.

On 1: replaced the relevant sprintf with snprintf.
On 2: worked around by adding a compiler define with a different name
 aliasing the character set variable used with a name that
 won't trigger the bison warning
On 3: This is due to the fact that there's a circular dependecy between
 mysys and dbug (among others). Turned the warning off by suppressing
 the duplicate library warning.
@gkodinov gkodinov requested a review from vaintroub January 9, 2026 13:39
Copy link
Contributor

@dr-m dr-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason why we are not working around the Bison bug in the earliest maintained branch (10.6)?

if (maybe_disable_binlog(mysql))
return -1;
sprintf(buff,"create database `%.*s`",FN_REFLEN,argv[1]);
snprintf(buff, sizeof(buff), "create database `%.*s`",FN_REFLEN,argv[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the sprintf changes had better be implemented, tested, and reviewed separately. In #2432 and #3613 we already had some effort on this, including some review comments.

Copy link
Contributor Author

@gkodinov gkodinov Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These PRs are about a year old?
The question is: is there anything wrong with the changes proposed?

My goal is simple: get a warning-free compile. Warnings are a bad false positive: they obscure my daily work.
Apparently a big-bang approach of fixing all of these is not going very fast. Can we go step-wise with this instead please?

Copy link
Contributor

@svoj svoj Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we should not hijack effort done in previous contributions. There're also #3075, #3076 and #3077.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we have agreed to take the iterative approach wrt sprintf->snprintf migration.
So the current "plan" is to keep this PR intact, but remove from it and backport the bison workaround and the mysys linker warnings workaround to 10.6. I'll follow up with a new PR about this. And an update to the current one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

5 participants