A compound of the formula I: or a pharmaceutically acceptable salt thereof, wherein: X is R is H, or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R' is H, or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R 1 is OH, H, C 1-6 alkyl, OC 1-6 alkyl, CH 2 OH, or C 1-6 akylOC 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, or X and R 1 together form a bicyclic ring system comprising a saturated carbocyclic ring fused to a heteroaryl ring having 1 N atom, said heteroaryl ring, optionally substituted with 1-4 substitutents independently selected from halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, heteroaryl, CN, or OC 1-6 alkyl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents, m is 0, 1, 2, 3, or 4, n is 0, or 1, R 2 and R 3 are each independently H or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, or R 2 and R 3 together form oxo, Y is CH 2 or O, R 4 is H, C 1-6 alkyl, or oxo, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R 5 is H, OH, C 1-6 alkyl, OC 1-6 alkyl, OC 1-6 alkylOC 1-6 alkyl, or halo, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, Z is R a is H, halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, or heteroaryl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents, R b is H, C 1-6 alkyl, or OC 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R c is C 1-6 alkyl, or 3- to 6-membered cycloalkyl, wherein alkyl or cycloalkyl substituents are further optionally substituted with 1-4 halogen substituents, and each R d is independently halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, heteroaryl, CN, or OC 1-6 alkyl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents. X is R is H, or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R' is H, or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R 1 is OH, H, C 1-6 alkyl, OC 1-6 alkyl, CH 2 OH, or C 1-6 akylOC 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, or X and R 1 together form a bicyclic ring system comprising a saturated carbocyclic ring fused to a heteroaryl ring having 1 N atom, said heteroaryl ring, optionally substituted with 1-4 substitutents independently selected from halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, heteroaryl, CN, or OC 1-6 alkyl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents, m is 0, 1, 2, 3, or 4, n is 0, or 1, R 2 and R 3 are each independently H or C 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, or R 2 and R 3 together form oxo, Y is CH 2 or O, R 4 is H, C 1-6 alkyl, or oxo, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R 5 is H, OH, C 1-6 alkyl, OC 1-6 alkyl, OC 1-6 alkylOC 1-6 alkyl, or halo, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, Z is R a is H, halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, or heteroaryl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents, R b is H, C 1-6 alkyl, or OC 1-6 alkyl, wherein alkyl substituents are further optionally substituted with 1-4 halogen substituents, R c is C 1-6 alkyl, or 3- to 6-membered cycloalkyl, wherein alkyl or cycloalkyl substituents are further optionally substituted with 1-4 halogen substituents, and each R d is independently halo, C 1-6 alkyl, 3- to 6-membered cycloalkyl, aryl, heteroaryl, CN, or OC 1-6 alkyl, wherein alkyl, cycloalkyl, aryl or heteroaryl substituents are further optionally substituted with 1-4 halogen substituents.