Skip to content

[fix](build) Fix --whole-archive linker error on macOS#61291

Open
airborne12 wants to merge 1 commit intoapache:masterfrom
airborne12:fix-cmake-whole-archive-macos
Open

[fix](build) Fix --whole-archive linker error on macOS#61291
airborne12 wants to merge 1 commit intoapache:masterfrom
airborne12:fix-cmake-whole-archive-macos

Conversation

@airborne12
Copy link
Member

@airborne12 airborne12 commented Mar 13, 2026

What problem does this PR solve?

Issue Number: N/A

Related PR: #61285

Problem Summary:

macOS ld64 does not support GNU ld's --whole-archive / --no-whole-archive linker options, causing link failure when building BE on macOS:

ld: unknown options: --whole-archive --no-whole-archive

This PR uses macOS-native -force_load with CMake's $<TARGET_FILE:lib> generator expression on Apple platforms instead. Fixes both doris_be (paimon factory registry libs) and doris_be_test (vector_search_test) link targets.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
      • BE compiles and links successfully on macOS (Apple Silicon).
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@airborne12
Copy link
Member Author

run buildall

macOS ld64 does not support GNU ld's --whole-archive/--no-whole-archive
options. Use -force_load with the target file path instead when building
on Apple platforms.

This fixes the link failure for doris_be when ENABLE_PAIMON_CPP is on,
and for doris_be_test with vector_search_test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@airborne12 airborne12 force-pushed the fix-cmake-whole-archive-macos branch from 0105dbe to 927c1c8 Compare March 13, 2026 01:13
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Mar 13, 2026
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.68% (19716/37426)
Line Coverage 36.25% (184197/508133)
Region Coverage 32.40% (142337/439343)
Branch Coverage 33.59% (62198/185168)

@airborne12
Copy link
Member Author

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 26819 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 927c1c80336f99e0b3afe0c9d5e46538a74aee79, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17621	4438	4327	4327
q2	q3	10647	781	503	503
q4	4678	360	253	253
q5	7550	1222	1033	1033
q6	175	180	152	152
q7	804	851	662	662
q8	10107	1455	1342	1342
q9	5308	4818	4615	4615
q10	6327	1907	1657	1657
q11	460	260	235	235
q12	736	583	474	474
q13	18029	2959	2182	2182
q14	231	237	219	219
q15	q16	746	759	664	664
q17	731	845	454	454
q18	5906	5413	5191	5191
q19	1265	984	600	600
q20	553	490	378	378
q21	4506	1808	1585	1585
q22	428	346	293	293
Total cold run time: 96808 ms
Total hot run time: 26819 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4734	4571	4590	4571
q2	q3	3888	4383	3905	3905
q4	968	1216	779	779
q5	4048	4412	4392	4392
q6	189	191	150	150
q7	1799	1726	1532	1532
q8	2452	2665	2561	2561
q9	7510	7665	7477	7477
q10	3806	3976	3650	3650
q11	514	434	409	409
q12	495	582	466	466
q13	2895	3141	2340	2340
q14	289	316	292	292
q15	q16	727	797	724	724
q17	1213	1415	1429	1415
q18	7390	6789	6549	6549
q19	873	845	866	845
q20	2039	2116	2012	2012
q21	3971	3420	3331	3331
q22	475	428	377	377
Total cold run time: 50275 ms
Total hot run time: 47777 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 168361 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 927c1c80336f99e0b3afe0c9d5e46538a74aee79, data reload: false

query5	4316	638	528	528
query6	333	220	205	205
query7	4219	478	270	270
query8	337	249	225	225
query9	8684	2737	2716	2716
query10	509	394	344	344
query11	6897	5094	4887	4887
query12	182	127	129	127
query13	1272	454	348	348
query14	5706	3736	3452	3452
query14_1	2860	2834	2789	2789
query15	205	193	177	177
query16	992	494	465	465
query17	1119	734	622	622
query18	2438	457	352	352
query19	218	219	190	190
query20	136	131	126	126
query21	213	134	112	112
query22	13342	13549	13304	13304
query23	15720	15509	15872	15509
query23_1	15792	15690	15823	15690
query24	8035	1697	1282	1282
query24_1	1333	1354	1299	1299
query25	580	536	459	459
query26	1457	288	156	156
query27	3264	551	335	335
query28	4808	1890	1860	1860
query29	856	558	487	487
query30	294	220	191	191
query31	1010	935	891	891
query32	86	68	71	68
query33	500	326	285	285
query34	964	911	537	537
query35	642	679	601	601
query36	1109	1111	970	970
query37	134	95	80	80
query38	3077	3007	2944	2944
query39	863	850	814	814
query39_1	793	831	811	811
query40	271	157	144	144
query41	68	62	61	61
query42	266	270	269	269
query43	244	264	230	230
query44	
query45	207	199	185	185
query46	895	1010	627	627
query47	2128	2141	2054	2054
query48	324	312	247	247
query49	618	462	386	386
query50	676	270	214	214
query51	4105	4121	4048	4048
query52	268	264	264	264
query53	297	340	286	286
query54	312	269	263	263
query55	90	90	79	79
query56	323	327	318	318
query57	1943	1648	1757	1648
query58	294	274	269	269
query59	2766	2950	2761	2761
query60	351	345	328	328
query61	151	154	147	147
query62	624	593	539	539
query63	313	279	277	277
query64	5109	1277	1002	1002
query65	
query66	1472	470	354	354
query67	24367	24398	24333	24333
query68	
query69	399	321	285	285
query70	988	990	999	990
query71	338	313	289	289
query72	2655	2628	2427	2427
query73	540	570	330	330
query74	9584	9580	9432	9432
query75	2854	2777	2495	2495
query76	2271	1036	697	697
query77	360	394	311	311
query78	10965	11013	10511	10511
query79	3129	757	568	568
query80	1772	641	543	543
query81	584	268	227	227
query82	986	151	119	119
query83	335	263	248	248
query84	259	120	102	102
query85	921	481	436	436
query86	492	305	308	305
query87	3140	3187	3010	3010
query88	3560	2653	2643	2643
query89	430	376	339	339
query90	2026	175	177	175
query91	166	160	139	139
query92	87	78	70	70
query93	1469	850	513	513
query94	648	318	296	296
query95	617	416	313	313
query96	643	521	226	226
query97	2451	2480	2377	2377
query98	243	225	232	225
query99	991	997	936	936
Total cold run time: 254134 ms
Total hot run time: 168361 ms

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

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants